主动设置zip文件修改时间

This commit is contained in:
嬴政 时
2025-05-15 19:39:37 +08:00
parent 3e885b1089
commit 5c2676afc7
@@ -336,9 +336,20 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Service
Directory.CreateDirectory(targetPath);
}
targetPath = Path.Combine(targetPath, fileInfo.FileTag + ".zip");
// 先记录源 ZIP 文件的修改时间
DateTime sourceLastWriteTime = File.GetLastWriteTimeUtc(absPath);
LogFactory.GetLogger("SentReport-SaveDb").Info($"zip文件的最后修改时间:{sourceLastWriteTime.ToString("yyyy-mm-dd HH:mm:dd:fff")}");
LogFactory.GetLogger("SentReport-SaveDb").Info("准备复制zip文件");
// 复制文件
File.Copy(absPath, targetPath);
// 强制设置目标 ZIP 文件的修改时间与源文件一致
File.SetLastWriteTimeUtc(targetPath, sourceLastWriteTime);
LogFactory.GetLogger("SentReport-SaveDb").Info($"准备生成.ok文件");
Thread.Sleep(1000);
File.Create(absPath + ".ok").Close();
LogFactory.GetLogger("SentReport-SaveDb").Info($"准备复制.ok文件");
File.Copy(absPath + ".ok", targetPath + ".ok");
LogFactory.GetLogger("SentReport-SaveDb").Info($"复制.ok文件完成");
}
else
{