tags:

views:

31

answers:

3

Given that I have a zip file called archive.zip that contains a file called customerData, how can I programmatically check the date of the file inside archive.zip? I'm using the command-line Winzip utility wzunzip, but I wouldn't object to possibly using something else.

I'm writing a .net application that will periodically read data from customerData. The file is very big and I want to abort the operation without extracting customerData if the date stamp has not been updated, indicating that there is new data to read.

+1  A: 

Via http://dotnetzip.codeplex.com/. There is no native way (that I know) to do that.

Example Code:

ZipFile z = ZipFile.Read(@"C:\archive.zip");
foreach (ZipEntry zEntry in z)
{
    Console.WriteLine(zEntry.LastModified.ToString());
}
Nate Bross
A: 

I think the easiest .NET API is DotNetZip, but SharpLibZip works as well. There are a number of pay libraries of which I've and enjoyed and successfullly used ChilCat.

UPDATE: If you don't mind scripting. 7zip command line provides the info

C:\temp\XpsTest>"c:\Program Files\7-zip\7z.exe" l "39 Clues.xps"

7-Zip 4.65  Copyright (c) 1999-2009 Igor Pavlov  2009-02-03

Listing archive: 39 Clues.xps


   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2009-09-10 23:06:58 .....          160          212  FixedDocumentSequence.fdseq
...
kenny
A: 

If I may be so bold, it sounds unlikely that checking a zip file periodically is a good solution to many problems, unless you have no control over how this data is being delivered to you?

If you could post a little more information about the problem/situation you are dealing with, I dare say the crew here might be able to come up with some more interesting possible solutions.?

A bit off-topic, but sometimes answering a problem with the right question isn't as helpful as getting an easier and cleaner problem to solve.. at least I like to think so.

Hope that helps..

Kieren Johnstone
Unfortunately, this method is set in stone. It used to be the case that new data came in daily and the program ran once daily to read the new data. My task is to make it run more than once a day and poll the data to see if it is new or not.
Rice Flour Cookies
Don't know who voted me down but if you could leave a comment that would be appreciated. Do you really think my answer is that unhelpful?
Kieren Johnstone