Is there any difference between ZIP files?

1.2k Views Asked by At

I created a ZIP file by using Windows compress and then I created another ZIP file by using WinRAR. In my output I have two different set of output!

List of folders do not appear in the ZIP file generated by Windows, but I have a list of folders as well with WinRAR created ZIP file.

  • Which one is the correct archive?
  • Have you ever faced with this issue?
  • How can I handle this situation?
  • Is there any other model also?

Output of Windows compressed ZIP file:

DirectoryName:data FileName:data.bin
DirectoryName: FileName:manifest.txt
DirectoryName:pdfs FileName:some.pdf

Output of WinRAR ZIP file:

DirectoryName: FileName:manifest.txt
DirectoryName:data FileName:
DirectoryName:data FileName:data.bin
DirectoryName:pdfs FileName:
DirectoryName:pdfs FileName:some.pdf

I am using this code for generating above output:

using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
    foreach (ZipArchiveEntry entry in archive.Entries)
    {
        TreeNodeDetails tnd = new TreeNodeDetails(entry.FullName, seq_folder_id++, NODETYPE.ZIPFILE, NODE_Format.DIRECTORY);
        Console.WriteLine("DirectoryName:" + tnd.directoryName + " FileName:" + tnd.fileName);
        InitiateTree(rootTreeNode, tnd);
    }
}
2

There are 2 best solutions below

8
On

yes there are several compression types, most common are Zip, GZip, and Rar. which type you want depends on what you will use it for, and what program you will be compressing/decompressing with, and since you seem to be writing your own, it should work fin for you to unzip as well. not much of a size difference between the three main types, although that depends on the size of the archive being zipped. so bassically its up to you!

if your worried something went wrong, you can unzip them and compare the contents, and then you can decide based on compressed size which one to keep. zip has always been more common, but most zip programs handle rar now too.

1
On

There's no functional difference between the two examples. For example:

DirectoryName:data FileName:data.bin

If the folder 'data' doesn't exist, it will be created, then the 'data.bin' file will be extracted and added to that folder.