C# 将文件添加到存档时,不要修改文件的编辑日期
我正在使用SharpCompress库创建我的zip存档。我成功地创建了Zip存档,但库会自动将文件的编辑日期更新为当前日期时间。我不要这种行为。我想的是:编辑日期将保持不变,即:存档中文件的编辑日期与存档前文件的编辑日期相同 如何避免这种行为?这是我的代码:C# 将文件添加到存档时,不要修改文件的编辑日期,c#,zip,sharpcompress,C#,Zip,Sharpcompress,我正在使用SharpCompress库创建我的zip存档。我成功地创建了Zip存档,但库会自动将文件的编辑日期更新为当前日期时间。我不要这种行为。我想的是:编辑日期将保持不变,即:存档中文件的编辑日期与存档前文件的编辑日期相同 如何避免这种行为?这是我的代码: private String CreaPacchettoZip(String idProcesso, String pdfBasePath) { List<String> listaPdfDiProcesso = Fi
private String CreaPacchettoZip(String idProcesso, String pdfBasePath)
{
List<String> listaPdfDiProcesso = FileHelper.EstraiListaPdfDaDirecotry(pdfBasePath);
String zipFile = Path.Combine(pdfBasePath, idProcesso + ".zip");
using (var archive = ZipArchive.Create())
{
foreach (String file in listaPdfDiProcesso)
{
archive.AddEntry(file, new FileInfo(pdfBasePath, file));
}
using (Stream newStream = File.Create(zipFile))
{
archive.SaveTo(newStream, SharpCompress.Common.CompressionType.None);
}
}
return zipFile;
}
在这里的某个地方
foreach (String file in listaPdfDiProcesso)
{ var fileInfo = new FileInfo(pdfBasePath, file);
// If here date is ~DateTime.Now read it some other way like File.Open from file and then set it to fileInfo if it has Setter or Date setting method
var originalFileCreationDate = e.DateItGotCreated; //DateItGotCreated is not actual propety or method.
archive.AddEntry(file, fileInfo);
}