public static async Task ZipArchive_InvalidStream(String zipname) { string filename = ZipTest.bad(zipname); using (var stream = await StreamHelpers.CreateTempCopyStream(filename)) Assert.Throws <InvalidDataException>(() => new ZipArchive(stream, ZipArchiveMode.Read)); }
public static async Task ReadNormal() { await ZipTest.IsZipSameAsDirAsync( ZipTest.zfile("normal.zip"), ZipTest.zfolder("normal"), ZipArchiveMode.Read); await ZipTest.IsZipSameAsDirAsync( ZipTest.zfile("fake64.zip"), ZipTest.zfolder("small"), ZipArchiveMode.Read); await ZipTest.IsZipSameAsDirAsync( ZipTest.zfile("empty.zip"), ZipTest.zfolder("empty"), ZipArchiveMode.Read); await ZipTest.IsZipSameAsDirAsync( ZipTest.zfile("appended.zip"), ZipTest.zfolder("small"), ZipArchiveMode.Read); await ZipTest.IsZipSameAsDirAsync( ZipTest.zfile("prepended.zip"), ZipTest.zfolder("small"), ZipArchiveMode.Read); await ZipTest.IsZipSameAsDirAsync( ZipTest.zfile("emptydir.zip"), ZipTest.zfolder("emptydir"), ZipArchiveMode.Read); await ZipTest.IsZipSameAsDirAsync( ZipTest.zfile("small.zip"), ZipTest.zfolder("small"), ZipArchiveMode.Read); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) // [ActiveIssue(846, PlatformID.AnyUnix)] { await ZipTest.IsZipSameAsDirAsync( ZipTest.zfile("unicode.zip"), ZipTest.zfolder("unicode"), ZipArchiveMode.Read); } }
public static async Task UnsupportedCompression() { //lzma compression method await UnsupportedCompressionRoutine(ZipTest.bad("LZMA.zip"), true); await UnsupportedCompressionRoutine(ZipTest.bad("invalidDeflate.zip"), false); }
public static async Task testFolder(String s) { var zs = new LocalMemoryStream(); await ZipTest.CreateFromDir(ZipTest.zfolder(s), zs, ZipArchiveMode.Update); ZipTest.IsZipSameAsDir(zs.Clone(), ZipTest.zfolder(s), ZipArchiveMode.Read, false, false); }
public static async Task ZipArchive_InvalidEntryTable(String zipname) { string filename = ZipTest.bad(zipname); using (ZipArchive archive = new ZipArchive(await StreamHelpers.CreateTempCopyStream(filename), ZipArchiveMode.Read)) Assert.Throws <InvalidDataException>(() => archive.Entries[0]); }
public static async Task OverwriteEntry() { //Overwrite file Stream testArchive = await StreamHelpers.CreateTempCopyStream(ZipTest.zfile("normal.zip")); using (ZipArchive archive = new ZipArchive(testArchive, ZipArchiveMode.Update, true)) { String fileName = ZipTest.zmodified(Path.Combine("overwrite", "first.txt")); ZipArchiveEntry e = archive.GetEntry("first.txt"); var file = FileData.GetFile(fileName); e.LastWriteTime = file.LastModifiedDate; using (var stream = await StreamHelpers.CreateTempCopyStream(fileName)) { using (Stream es = e.Open()) { es.SetLength(0); stream.CopyTo(es); } } } ZipTest.IsZipSameAsDir(testArchive, ZipTest.zmodified("overwrite"), ZipArchiveMode.Read, false, false); }
public static async Task ZipArchiveEntry_InvalidUpdate(String zipname) { string filename = ZipTest.bad(zipname); Stream updatedCopy = await StreamHelpers.CreateTempCopyStream(filename); String name; Int64 length, compressedLength; DateTimeOffset lastWriteTime; using (ZipArchive archive = new ZipArchive(updatedCopy, ZipArchiveMode.Update, true)) { ZipArchiveEntry e = archive.Entries[0]; name = e.FullName; lastWriteTime = e.LastWriteTime; length = e.Length; compressedLength = e.CompressedLength; Assert.Throws <InvalidDataException>(() => e.Open()); //"Should throw on open" } //make sure that update mode preserves that unreadable file using (ZipArchive archive = new ZipArchive(updatedCopy, ZipArchiveMode.Update)) { ZipArchiveEntry e = archive.Entries[0]; Assert.Equal(name, e.FullName); //"Name isn't the same" Assert.Equal(lastWriteTime, e.LastWriteTime); //"LastWriteTime not the same" Assert.Equal(length, e.Length); //"Length isn't the same" Assert.Equal(compressedLength, e.CompressedLength); //"CompressedLength isn't the same" Assert.Throws <InvalidDataException>(() => e.Open()); //"Should throw on open" } }
public static async Task ZipArchiveEntry_InvalidLastWriteTime_Read() { using (ZipArchive archive = new ZipArchive(await StreamHelpers.CreateTempCopyStream( ZipTest.bad("invaliddate.zip")), ZipArchiveMode.Read)) { Assert.Equal(new DateTime(1980, 1, 1, 0, 0, 0), archive.Entries[0].LastWriteTime.DateTime); //"Date isn't correct on invalid date" } }
public static async Task TestStreamingRead(string zipFile, string zipFolder) { using (var stream = await StreamHelpers.CreateTempCopyStream(ZipTest.zfile(zipFile))) { Stream wrapped = new WrappedStream(stream, true, false, false, null); ZipTest.IsZipSameAsDir(wrapped, ZipTest.zfolder(zipFolder), ZipArchiveMode.Read, false, false); Assert.False(wrapped.CanRead, "Wrapped stream should be closed at this point"); //check that it was closed } }
public static async Task ZipWithInvalidFileNames_ParsedBasedOnSourceOS(string zipName, string fileName) { using (Stream stream = await StreamHelpers.CreateTempCopyStream(ZipTest.compat(zipName))) using (ZipArchive archive = new ZipArchive(stream)) { Assert.Equal(1, archive.Entries.Count); ZipArchiveEntry entry = archive.Entries[0]; Assert.Equal(fileName, entry.Name); } }
public static async Task testCreate(String folder, bool seekable) { using (var s = new MemoryStream()) { var testStream = new WrappedStream(s, false, true, seekable, null); await ZipTest.CreateFromDir(ZipTest.zfolder(folder), testStream, ZipArchiveMode.Create); ZipTest.IsZipSameAsDir(s, ZipTest.zfolder(folder), ZipArchiveMode.Read, false, false); } }
public static void EmptyEntryTest(ZipArchiveMode mode) { String data1 = "test data written to file."; String data2 = "more test data written to file."; DateTimeOffset lastWrite = new DateTimeOffset(1992, 4, 5, 12, 00, 30, new TimeSpan(-5, 0, 0)); var baseline = new LocalMemoryStream(); using (ZipArchive archive = new ZipArchive(baseline, mode)) { ZipTest.AddEntry(archive, "data1.txt", data1, lastWrite); ZipArchiveEntry e = archive.CreateEntry("empty.txt"); e.LastWriteTime = lastWrite; using (Stream s = e.Open()) { } ZipTest.AddEntry(archive, "data2.txt", data2, lastWrite); } var test = new LocalMemoryStream(); using (ZipArchive archive = new ZipArchive(test, mode)) { ZipTest.AddEntry(archive, "data1.txt", data1, lastWrite); ZipArchiveEntry e = archive.CreateEntry("empty.txt"); e.LastWriteTime = lastWrite; ZipTest.AddEntry(archive, "data2.txt", data2, lastWrite); } //compare Assert.True(ZipTest.ArraysEqual(baseline.ToArray(), test.ToArray()), "Arrays didn't match"); //second test, this time empty file at end baseline = baseline.Clone(); using (ZipArchive archive = new ZipArchive(baseline, mode)) { ZipTest.AddEntry(archive, "data1.txt", data1, lastWrite); ZipArchiveEntry e = archive.CreateEntry("empty.txt"); e.LastWriteTime = lastWrite; using (Stream s = e.Open()) { } } test = test.Clone(); using (ZipArchive archive = new ZipArchive(test, mode)) { ZipTest.AddEntry(archive, "data1.txt", data1, lastWrite); ZipArchiveEntry e = archive.CreateEntry("empty.txt"); e.LastWriteTime = lastWrite; } //compare Assert.True(ZipTest.ArraysEqual(baseline.ToArray(), test.ToArray()), "Arrays didn't match after update"); }
public static async Task AddFileToArchive() { //add file var testArchive = await StreamHelpers.CreateTempCopyStream(ZipTest.zfile("normal.zip")); using (ZipArchive archive = new ZipArchive(testArchive, ZipArchiveMode.Update, true)) { await updateArchive(archive, ZipTest.zmodified(Path.Combine("addFile", "added.txt")), "added.txt"); } ZipTest.IsZipSameAsDir(testArchive, ZipTest.zmodified("addFile"), ZipArchiveMode.Read, false, false); }
public static async Task CompatibilityTests() { ZipTest.IsZipSameAsDir(await StreamHelpers.CreateTempCopyStream( ZipTest.compat("7zip.zip")), ZipTest.zfolder("normal"), ZipArchiveMode.Update, false, false); ZipTest.IsZipSameAsDir(await StreamHelpers.CreateTempCopyStream( ZipTest.compat("windows.zip")), ZipTest.zfolder("normalWithoutEmptyDir"), ZipArchiveMode.Update, true, false); ZipTest.IsZipSameAsDir(await StreamHelpers.CreateTempCopyStream( ZipTest.compat("dotnetzipstreaming.zip")), ZipTest.zfolder("normal"), ZipArchiveMode.Update, true, true); ZipTest.IsZipSameAsDir(await StreamHelpers.CreateTempCopyStream( ZipTest.compat("sharpziplib.zip")), ZipTest.zfolder("normalWithoutEmptyDir"), ZipArchiveMode.Update, true, true); ZipTest.IsZipSameAsDir(await StreamHelpers.CreateTempCopyStream( ZipTest.compat("xceedstreaming.zip")), ZipTest.zfolder("normal"), ZipArchiveMode.Update, true, true); }
public static async Task CompatibilityTestsMsFiles() { ZipTest.IsZipSameAsDir(await StreamHelpers.CreateTempCopyStream( ZipTest.compat("excel.xlsx")), ZipTest.compat("excel"), ZipArchiveMode.Update, true, true); ZipTest.IsZipSameAsDir(await StreamHelpers.CreateTempCopyStream( ZipTest.compat("powerpoint.pptx")), ZipTest.compat("powerpoint"), ZipArchiveMode.Update, true, true); ZipTest.IsZipSameAsDir(await StreamHelpers.CreateTempCopyStream( ZipTest.compat("word.docx")), ZipTest.compat("word"), ZipArchiveMode.Update, true, true); ZipTest.IsZipSameAsDir(await StreamHelpers.CreateTempCopyStream( ZipTest.compat("silverlight.xap")), ZipTest.compat("silverlight"), ZipArchiveMode.Update, true, true); ZipTest.IsZipSameAsDir(await StreamHelpers.CreateTempCopyStream( ZipTest.compat("packaging.package")), ZipTest.compat("packaging"), ZipArchiveMode.Update, true, true); }
public static async Task UnsupportedCompressionRoutine(String zipname, Boolean throwsOnOpen) { // using (ZipArchive archive = ZipFile.OpenRead(filename)) string filename = ZipTest.bad(zipname); using (ZipArchive archive = new ZipArchive(await StreamHelpers.CreateTempCopyStream(filename), ZipArchiveMode.Read)) { ZipArchiveEntry e = archive.Entries[0]; if (throwsOnOpen) { Assert.Throws <InvalidDataException>(() => e.Open()); //"should throw on open" } else { using (Stream s = e.Open()) { Assert.Throws <InvalidDataException>(() => s.ReadByte()); //"Unreadable stream" } } } Stream updatedCopy = await StreamHelpers.CreateTempCopyStream(filename); String name; Int64 length, compressedLength; DateTimeOffset lastWriteTime; using (ZipArchive archive = new ZipArchive(updatedCopy, ZipArchiveMode.Update, true)) { ZipArchiveEntry e = archive.Entries[0]; name = e.FullName; lastWriteTime = e.LastWriteTime; length = e.Length; compressedLength = e.CompressedLength; Assert.Throws <InvalidDataException>(() => e.Open()); //"Should throw on open" } //make sure that update mode preserves that unreadable file using (ZipArchive archive = new ZipArchive(updatedCopy, ZipArchiveMode.Update)) { ZipArchiveEntry e = archive.Entries[0]; Assert.Equal(name, e.FullName); //"Name isn't the same" Assert.Equal(lastWriteTime, e.LastWriteTime); //"LastWriteTime not the same" Assert.Equal(length, e.Length); //"Length isn't the same" Assert.Equal(compressedLength, e.CompressedLength); //"CompressedLength isn't the same" Assert.Throws <InvalidDataException>(() => e.Open()); //"Should throw on open" } }
public static async Task ReadStreaming() { //don't include large, because that means loading the whole thing in memory await TestStreamingRead(ZipTest.zfile("normal.zip"), ZipTest.zfolder("normal")); await TestStreamingRead(ZipTest.zfile("fake64.zip"), ZipTest.zfolder("small")); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) // [ActiveIssue(846, PlatformID.AnyUnix)] { await TestStreamingRead(ZipTest.zfile("unicode.zip"), ZipTest.zfolder("unicode")); } await TestStreamingRead(ZipTest.zfile("empty.zip"), ZipTest.zfolder("empty")); await TestStreamingRead(ZipTest.zfile("appended.zip"), ZipTest.zfolder("small")); await TestStreamingRead(ZipTest.zfile("prepended.zip"), ZipTest.zfolder("small")); await TestStreamingRead(ZipTest.zfile("emptydir.zip"), ZipTest.zfolder("emptydir")); }
public static async Task ReadStreamOps() { using (ZipArchive archive = new ZipArchive(await StreamHelpers.CreateTempCopyStream(ZipTest.zfile("normal.zip")), ZipArchiveMode.Read)) { foreach (ZipArchiveEntry e in archive.Entries) { using (Stream s = e.Open()) { Assert.True(s.CanRead, "Can read to read archive"); Assert.False(s.CanWrite, "Can't write to read archive"); Assert.False(s.CanSeek, "Can't seek on archive"); Assert.Equal(ZipTest.LengthOfUnseekableStream(s), e.Length); //"Length is not correct on unseekable stream" } } } }
public static async Task InvalidDates() { using (ZipArchive archive = new ZipArchive(await StreamHelpers.CreateTempCopyStream( ZipTest.bad("invaliddate.zip")), ZipArchiveMode.Read)) { Assert.Equal(new DateTime(1980, 1, 1, 0, 0, 0), archive.Entries[0].LastWriteTime.DateTime); //"Date isn't correct on invalid date" } using (ZipArchive archive = new ZipArchive(new MemoryStream(), ZipArchiveMode.Create)) { ZipArchiveEntry entry = archive.CreateEntry("test"); Assert.Throws <ArgumentOutOfRangeException>(() => { entry.LastWriteTime = new DateTimeOffset(1979, 12, 3, 5, 6, 2, new TimeSpan()); }); //"should throw on bad date" Assert.Throws <ArgumentOutOfRangeException>(() => { entry.LastWriteTime = new DateTimeOffset(2980, 12, 3, 5, 6, 2, new TimeSpan()); }); //"Should throw on bad date" } }
public static async Task UpdateReadNormal() { ZipTest.IsZipSameAsDir( await StreamHelpers.CreateTempCopyStream(ZipTest.zfile("normal.zip")), ZipTest.zfolder("normal"), ZipArchiveMode.Update, false, false); ZipTest.IsZipSameAsDir( await StreamHelpers.CreateTempCopyStream(ZipTest.zfile("fake64.zip")), ZipTest.zfolder("small"), ZipArchiveMode.Update, false, false); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { ZipTest.IsZipSameAsDir( await StreamHelpers.CreateTempCopyStream(ZipTest.zfile("unicode.zip")), ZipTest.zfolder("unicode"), ZipArchiveMode.Update, false, false); } ZipTest.IsZipSameAsDir( await StreamHelpers.CreateTempCopyStream(ZipTest.zfile("empty.zip")), ZipTest.zfolder("empty"), ZipArchiveMode.Update, false, false); ZipTest.IsZipSameAsDir( await StreamHelpers.CreateTempCopyStream(ZipTest.zfile("appended.zip")), ZipTest.zfolder("small"), ZipArchiveMode.Update, false, false); ZipTest.IsZipSameAsDir( await StreamHelpers.CreateTempCopyStream(ZipTest.zfile("prepended.zip")), ZipTest.zfolder("small"), ZipArchiveMode.Update, false, false); }
public static async Task InvalidInstanceMethods() { Stream zipFile = await StreamHelpers.CreateTempCopyStream(ZipTest.zfile("normal.zip")); using (ZipArchive archive = new ZipArchive(zipFile, ZipArchiveMode.Update)) { //non-existent entry Assert.True(null == archive.GetEntry("nonExistentEntry")); //"Should return null on non-existent entry name" //null/empty string Assert.Throws <ArgumentNullException>(() => archive.GetEntry(null)); //"Should throw on null entry name" ZipArchiveEntry entry = archive.GetEntry("first.txt"); //null/empty string Assert.Throws <ArgumentException>(() => archive.CreateEntry("")); //"Should throw on empty entry name" Assert.Throws <ArgumentNullException>(() => archive.CreateEntry(null)); //"should throw on null entry name" } }
public static async Task ZipArchive_InvalidEntry(String zipname, Boolean throwsOnOpen) { string filename = ZipTest.bad(zipname); using (ZipArchive archive = new ZipArchive(await StreamHelpers.CreateTempCopyStream(filename), ZipArchiveMode.Read)) { ZipArchiveEntry e = archive.Entries[0]; if (throwsOnOpen) { Assert.Throws <InvalidDataException>(() => e.Open()); //"should throw on open" } else { using (Stream s = e.Open()) { Assert.Throws <InvalidDataException>(() => s.ReadByte()); //"Unreadable stream" } } } }
public static async Task AppendToEntry() { //append Stream testArchive = await StreamHelpers.CreateTempCopyStream(ZipTest.zfile("normal.zip")); using (ZipArchive archive = new ZipArchive(testArchive, ZipArchiveMode.Update, true)) { ZipArchiveEntry e = archive.GetEntry("first.txt"); using (StreamWriter s = new StreamWriter(e.Open())) { s.BaseStream.Seek(0, SeekOrigin.End); s.Write("\r\n\r\nThe answer my friend, is blowin' in the wind."); } var file = FileData.GetFile(ZipTest.zmodified(Path.Combine("append", "first.txt"))); e.LastWriteTime = file.LastModifiedDate; } ZipTest.IsZipSameAsDir(testArchive, ZipTest.zmodified("append"), ZipArchiveMode.Read, false, false); }
public static async Task DeleteAndMoveEntries() { //delete and move var testArchive = await StreamHelpers.CreateTempCopyStream(ZipTest.zfile("normal.zip")); using (ZipArchive archive = new ZipArchive(testArchive, ZipArchiveMode.Update, true)) { ZipArchiveEntry toBeDeleted = archive.GetEntry("binary.wmv"); toBeDeleted.Delete(); toBeDeleted.Delete(); //delete twice should be okay ZipArchiveEntry moved = archive.CreateEntry("notempty/secondnewname.txt"); ZipArchiveEntry orig = archive.GetEntry("notempty/second.txt"); using (Stream origMoved = orig.Open(), movedStream = moved.Open()) { origMoved.CopyTo(movedStream); } moved.LastWriteTime = orig.LastWriteTime; orig.Delete(); } ZipTest.IsZipSameAsDir(testArchive, ZipTest.zmodified("deleteMove"), ZipArchiveMode.Read, false, false); }
public static async Task UpdateModeInvalidOperations() { using (LocalMemoryStream ms = await LocalMemoryStream.readAppFileAsync(ZipTest.zfile("normal.zip"))) { ZipArchive target = new ZipArchive(ms, ZipArchiveMode.Update, true); ZipArchiveEntry edeleted = target.GetEntry("first.txt"); Stream s = edeleted.Open(); //invalid ops while entry open Assert.Throws <IOException>(() => edeleted.Open()); Assert.Throws <InvalidOperationException>(() => { var x = edeleted.Length; }); Assert.Throws <InvalidOperationException>(() => { var x = edeleted.CompressedLength; }); Assert.Throws <IOException>(() => edeleted.Delete()); s.Dispose(); //invalid ops on stream after entry closed Assert.Throws <ObjectDisposedException>(() => s.ReadByte()); Assert.Throws <InvalidOperationException>(() => { var x = edeleted.Length; }); Assert.Throws <InvalidOperationException>(() => { var x = edeleted.CompressedLength; }); edeleted.Delete(); //invalid ops while entry deleted Assert.Throws <InvalidOperationException>(() => edeleted.Open()); Assert.Throws <InvalidOperationException>(() => { edeleted.LastWriteTime = new DateTimeOffset(); }); ZipArchiveEntry e = target.GetEntry("notempty/second.txt"); target.Dispose(); Assert.Throws <ObjectDisposedException>(() => { var x = target.Entries; }); Assert.Throws <ObjectDisposedException>(() => target.CreateEntry("dirka")); Assert.Throws <ObjectDisposedException>(() => e.Open()); Assert.Throws <ObjectDisposedException>(() => e.Delete()); Assert.Throws <ObjectDisposedException>(() => { e.LastWriteTime = new DateTimeOffset(); }); } }
public static async Task StrangeFiles5() { ZipTest.IsZipSameAsDir(await StreamHelpers.CreateTempCopyStream( ZipTest.strange("filenameTimeAndSizesDifferentInLH.zip")), ZipTest.zfolder("verysmall"), ZipArchiveMode.Update, true, false); }
public static async Task StrangeFiles4() { ZipTest.IsZipSameAsDir(await StreamHelpers.CreateTempCopyStream( ZipTest.strange("dataDescriptor.zip")), ZipTest.zfolder("normalWithoutBinary"), ZipArchiveMode.Update, true, false); }
public static async Task StrangeFiles3() { ZipTest.IsZipSameAsDir(await StreamHelpers.CreateTempCopyStream( ZipTest.strange(Path.Combine("extradata", "zip64ThenExtraData.zip"))), ZipTest.zfolder("verysmall"), ZipArchiveMode.Update, false, false); }
public static async Task StrangeFiles1() { ZipTest.IsZipSameAsDir(await StreamHelpers.CreateTempCopyStream( ZipTest.strange(Path.Combine("extradata", "extraDataLHandCDentryAndArchiveComments.zip"))), ZipTest.zfolder("verysmall"), ZipArchiveMode.Update, false, false); }
public static async Task UpdateModifications() { //delete and move var testArchive = await StreamHelpers.CreateTempCopyStream(ZipTest.zfile("normal.zip")); using (ZipArchive archive = new ZipArchive(testArchive, ZipArchiveMode.Update, true)) { ZipArchiveEntry toBeDeleted = archive.GetEntry("binary.wmv"); toBeDeleted.Delete(); toBeDeleted.Delete(); //delete twice should be okay ZipArchiveEntry moved = archive.CreateEntry("notempty/secondnewname.txt"); ZipArchiveEntry orig = archive.GetEntry("notempty/second.txt"); using (Stream origMoved = orig.Open(), movedStream = moved.Open()) { origMoved.CopyTo(movedStream); } moved.LastWriteTime = orig.LastWriteTime; orig.Delete(); } ZipTest.IsZipSameAsDir(testArchive, ZipTest.zmodified("deleteMove"), ZipArchiveMode.Read, false, false); //append testArchive = await StreamHelpers.CreateTempCopyStream(ZipTest.zfile("normal.zip")); using (ZipArchive archive = new ZipArchive(testArchive, ZipArchiveMode.Update, true)) { ZipArchiveEntry e = archive.GetEntry("first.txt"); using (StreamWriter s = new StreamWriter(e.Open())) { s.BaseStream.Seek(0, SeekOrigin.End); s.Write("\r\n\r\nThe answer my friend, is blowin' in the wind."); } e.LastWriteTime = new DateTimeOffset(2010, 7, 7, 11, 57, 18, new TimeSpan(-7, 0, 0)); } ZipTest.IsZipSameAsDir(testArchive, ZipTest.zmodified("append"), ZipArchiveMode.Read, false, false); //Overwrite file testArchive = await StreamHelpers.CreateTempCopyStream(ZipTest.zfile("normal.zip")); using (ZipArchive archive = new ZipArchive(testArchive, ZipArchiveMode.Update, true)) { String fileName = ZipTest.zmodified(Path.Combine("overwrite", "first.txt")); ZipArchiveEntry e = archive.GetEntry("first.txt"); var file = FileData.GetFile(fileName); e.LastWriteTime = file.LastModifiedDate; using (var stream = await StreamHelpers.CreateTempCopyStream(fileName)) { using (Stream es = e.Open()) { es.SetLength(0); stream.CopyTo(es); } } } ZipTest.IsZipSameAsDir(testArchive, ZipTest.zmodified("overwrite"), ZipArchiveMode.Read, false, false); }