干度和6个物性参数计算验算过的方法

This commit is contained in:
2026-04-29 11:49:34 +08:00
parent e3641ebe84
commit 53ded58da3
6 changed files with 1239 additions and 1181 deletions

View File

@@ -605,8 +605,7 @@ namespace CapMachine.Wpf.ViewModels
{
if (File.Exists(item.FilePath))//是否存在文件
{
//Copy文件
CopyToFile(item.FilePath, TargetFilePath);
ExportFilteredCsvToFolder(item.FilePath, TargetFilePath);
}
else
{
@@ -675,6 +674,34 @@ namespace CapMachine.Wpf.ViewModels
File.Copy(SourceFilePath, destinationFilePath, true); // true 表示如果目标文件已存在,则覆盖
}
public void ExportFilteredCsvToFolder(string sourceFilePath, string targetFolderPath)
{
if (string.IsNullOrWhiteSpace(sourceFilePath) || string.IsNullOrWhiteSpace(targetFolderPath))
{
return;
}
string destinationFilePath = Path.Combine(targetFolderPath, Path.GetFileName(sourceFilePath));
try
{
using (var reader = new StreamReader(sourceFilePath, Encoding.UTF8, true))
using (var csvReader = new CsvReader(reader, CultureInfo.CurrentCulture))
using (var writer = new StreamWriter(destinationFilePath, false, Encoding.UTF8))
using (var csvWriter = new CsvWriter(writer, CultureInfo.CurrentCulture))
{
csvReader.Context.RegisterClassMap<CsvRecordModelMap>();
csvWriter.Context.RegisterClassMap<CsvRecordModelMap>();
csvWriter.WriteRecords(csvReader.GetRecords<CsvRecordModel>());
}
}
catch (Exception ex)
{
Logger?.Error($"导出CSV失败: {ex.Message}");
System.Windows.MessageBox.Show($"导出CSV失败: {ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
/// <summary>
/// 复制文件夹及文件
/// </summary>