Lastwritetime changes when extracting zipfile in c #?

I am using Sharpziplib version 0.86 to extract a zip file. It works fine, but when you extract the winzip file through Lastwritetime code it changes in seconds ...

Used it also File.SetLastWriteTime(fullPath, theEntry.DateTime);

Actual Lastwritetime file: 4/8/2010 2:29:03PM After zip this file using winzip and when extracting this file using code, the extracted Lastwritetime file will change to 4/8/2010 2:29:04PM .. Is there any fix for this ???

+4
source share
2 answers

I got this answer from the Sharpziplib forum

Hello

This seems to be a WinZip error. I have not noticed this before.

I did this test:

1) Use WinZip to add the file to zip. In WinZip, click Properties and Details. Browse through the parts list and find the file timestamp.

2) Use SharpZipLib to create a similar zip file with the same input file. Open the result in Winzip and look at Properties> Details for the timestamp of the file.

My input file has a Modified timestamp (file properties) 2010-12-14 15:51:28, and in my test SharpZipLib correctly saved it in zip, and WinZip saved it as 2010-12-14 15: 51:30

In other words, WinZip added 2 seconds when it put it in a zip code. After extraction (with WinZip or SharpZip), Modified is now 15:51:30 instead of the original 15:51:28.

Surprisingly, such an obvious error in WinZip can be unregistered and uncommitted for so long. If you have a paid version, you should definitely raise an error with them.

I just remembered the 2 second drill down at the old 8.3 timeframes.

Quick google found this ...

Quote: โ€œThe original DOS file system had only 32 bytes to represent the file in the directory. A very limited file name 8.3 and a limited degree of detail (2 seconds) in the file date are fixed in Win32 (VFAT) file systems.โ€ from http://www.xxcopy.com/xxcopy15.htm

The Zip format allows only 2-second detail in a standard timestamp entry. Date and time are encoded in the standard MS-DOS format.

An optional NTFS additional data field (0x000a) may be included, which may include the last modification time, last access time, and creation time. WinZip does not seem to create it. SharpZip will use it if it is present, but as far as I can see, it is not created when using FastZip to create a zip. This can be a useful option to add to your code. You can create it manually if you use ZipFile.

Hope this helps, David

+2
source

I think it may just be the operating system that causes this. I tried what happens in Explorer. I have a text file with a modified time stamp of 17:06:45. I right-click on the file and select Send to | Compressed (compressed) folder. Then right-click on the new zip file and select "Extract All ...", then "Next", "Next", "Finish". Now the extracted text file has a time stamp of 17:06:46.

The same thing happens when I use 7-Zip or WinRar. But then this only happens when using the .zip file. If I let them create a .7Z or .RAR file, the timestamp will not be changed.

Found wikipedia article on zip format. If you search within โ€œsecondsโ€, you will find a section describing that the ZIP file system mimics the DOS FAT file system, which only has a two-second temporary resolution.

+2
source

Source: https://habr.com/ru/post/1332198/


All Articles