EmitTimesInWindowsFormatWhenSaving Property

DotNetZip

Ionic Zip Library v1.9.1.6 EmitTimesInWindowsFormatWhenSaving Property
ReferenceIonic.ZipZipFileEmitTimesInWindowsFormatWhenSaving
Specifies whether the Creation, Access, and Modified times for entries added to the zip file will be emitted in “Windows format” when the zip archive is saved.
Declaration Syntax
C# Visual Basic Visual C++
public bool EmitTimesInWindowsFormatWhenSaving { get; set; }
Public Property EmitTimesInWindowsFormatWhenSaving As Boolean
	Get
	Set
public:
property bool EmitTimesInWindowsFormatWhenSaving {
	bool get ();
	void set (bool value);
}
Remarks

An application creating a zip archive can use this flag to explicitly specify that the file times for the entries should or should not be stored in the zip archive in the format used by Windows. By default this flag is true, meaning the Windows-format times are stored in the zip archive.

When adding an entry from a file or directory, the Creation (CreationTime), Access (AccessedTime), and Modified (ModifiedTime) times for the given entry are automatically set from the filesystem values. When adding an entry from a stream or string, all three values are implicitly set to DateTime.Now. Applications can also explicitly set those times by calling SetEntryTimes(DateTime, DateTime, DateTime).

PKWARE's zip specification describes multiple ways to format these times in a zip file. One is the format Windows applications normally use: 100ns ticks since January 1, 1601 UTC. The other is a format Unix applications typically use: seconds since January 1, 1970 UTC. Each format can be stored in an "extra field" in the zip entry when saving the zip archive. The former uses an extra field with a Header Id of 0x000A, while the latter uses a header ID of 0x5455, although you probably don't need to know that.

Not all tools and libraries can interpret these fields. Windows compressed folders is one that can read the Windows Format timestamps, while I believe the Infozip tools can read the Unix format timestamps. Some tools and libraries may be able to read only one or the other. DotNetZip can read or write times in either or both formats.

The times stored are taken from ModifiedTime, AccessedTime, and CreationTime.

The value set here applies to all entries subsequently added to the ZipFile.

This property is not mutually exclusive of the EmitTimesInUnixFormatWhenSaving property. It is possible and legal and valid to produce a zip file that contains timestamps encoded in the Unix format as well as in the Windows format, in addition to the LastModified time attached to each entry in the archive, a time that is always stored in "DOS format". And, notwithstanding the names PKWare uses for these time formats, any of them can be read and written by any computer, on any operating system. But, there are no guarantees that a program running on Mac or Linux will gracefully handle a zip file with "Windows" formatted times, or that an application that does not use DotNetZip but runs on Windows will be able to handle file times in Unix format.

When in doubt, test. Sorry, I haven't got a complete list of tools and which sort of timestamps they can use and will tolerate. If you get any good information and would like to pass it on, please do so and I will include that information in this documentation.

Examples
This example shows how to save a zip file that contains file timestamps in a format normally used by Unix.
CopyC#
using (var zip = new ZipFile())
{
    // produce a zip file the Mac will like
    zip.EmitTimesInWindowsFormatWhenSaving = false;
    zip.EmitTimesInUnixFormatWhenSaving = true;
    zip.AddDirectory(directoryToZip, "files");
    zip.Save(outputFile);
}
CopyVB.NET
Using zip As New ZipFile
    '' produce a zip file the Mac will like
    zip.EmitTimesInWindowsFormatWhenSaving = False
    zip.EmitTimesInUnixFormatWhenSaving = True
    zip.AddDirectory(directoryToZip, "files")
    zip.Save(outputFile)
End Using

Assembly: Ionic.Zip (Module: Ionic.Zip) Version: 1.9.1.8 (1.9.1.8)