From 65cfb87ad9337c14a9eeb686e413d498fc556902 Mon Sep 17 00:00:00 2001 From: Michele Di Maria Date: Thu, 14 Dec 2017 17:50:10 +0100 Subject: [PATCH] DateTime of a ZipEntry when updating a ZipFile I just run in this same limit: http://community.sharpdevelop.net/forums/t/19039.aspx , so I added a new method. Tested and working on my project. Thanks, Mdm PS: I certify that I own, and have sufficient rights to contribute, all source code and related material intended to be compiled or integrated with the source code for the SharpZipLib open source product (the "Contribution"). My Contribution is licensed under the MIT License. --- src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs b/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs index b65895adc..f71df5d93 100644 --- a/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs +++ b/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs @@ -1517,6 +1517,34 @@ public void Add(string fileName, string entryName) } + /// + /// Add a file to the archive. + /// + /// The name of the file to add. + /// The name to use for the on the Zip file created. + /// The DateTime to use for the on the Zip file created. + /// Argument supplied is null. + public void Add(string fileName, string entryName, DateTime entryDateTime) + { + if (fileName == null) + { + throw new ArgumentNullException(nameof(fileName)); + } + + if (entryName == null) + { + throw new ArgumentNullException(nameof(entryName)); + } + + CheckUpdating(); + contentsEdited_ = true; + + ZipEntry entry = EntryFactory.MakeFileEntry(entryName); + entry.DateTime = entryDateTime; + AddUpdate(new ZipUpdate(fileName, entry)); + } + + /// /// Add a file entry with data. ///