This project is read-only.

CreationTime/AccessedTime Question

May 25, 2010 at 4:59 PM

The project I'm working on requires us to modify a few files and add a file to an existing zip which will be vended to customers.  For piracy-related reasons we're going to drop a piece of data in one file (non-user identifiable) in case we find any vended files out in the wild.  It happens that all the files in the zip have a modified date but have no value for created date or accessed date.  We would rather not call attention to the file(s) we've modified inside the zip for obvious reasons, but I haven't found a way to set the CreationTime or AccessedTime values to null for a given file within the zip.  Based on DotNetZip's usage of the LastModified property is it even possible for me to set null values for CreationTime or AccessedTime?  If so, any information you can give me on how is much appreciated.

May 25, 2010 at 10:11 PM

Yes, I think so - you can use ZipEntry.SetEntryTimes().  This method is present in v1.9 of the library.

You don't want "null".  The DateTime is a structure if I'm not mistaken, so null is not a valid value.   Maybe you want new System.DateTime(1, 1, 1, 0, 0, 0, DateTimeKind.Utc);   Or some other "fixed time." 

The next question is, do you want the times to be emitted in a high-resolution "NTFS" format?  That happens by default in v1.9.  If you just want to the "DOS" time, then you can set ZipEntry.EmitTimesInWindowsFormatWhenSaving to false (there's also a similar property on ZipFile).

In that case no Creation or Access time is stored for the entry.  Read the doc for more info.



May 26, 2010 at 3:21 PM

Thanks, Cheeso.  Setting EmitTimesInWindowsFormatWhenSaving to false gave me the results I was after.  Much appreciated.