1

I'm creating my zip archive using SharpCompress library. I successfully create Zip archive but, the library, automaticcally update file's edit date to current datetime. I don't want this behaviour. What I would is: the edit date will be unchanged (i.e.: the edit date of file in the archive is the same of the file before archiviation).

How can avoid this behaviour? This is my code:

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;
    }
BAD_SEED
  • 4,840
  • 11
  • 53
  • 110

1 Answers1

0

Somewhere in here

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);
        }
Matas Vaitkevicius
  • 58,075
  • 31
  • 238
  • 265