Search code examples
c#zipextractarchiveunzip

How to Read file properties from a zip file ..?


I have a zip file and I want to read file properties from this zip file and if file is according to my information Like if I want .doc file and in zip the file is .doc then copy it. And if there is a zip file which contains Folder and that folder contains Zip File and in that zip file there is another folder and then there is required file so how can I get that required file and also save full path of that file.? and I want to do this in c#.


Solution

  • With DotNetZip you can read the files in a zip file as easy as:

    string zipPath = @"c:\example\MyFile.zip";
    using (zip archive = ZipFile.OpenRead(zipPath))
    {
          foreach (ZipArchiveEntry entry in archive.Entries)
          {
              System.Console.WriteLine(entry.);
          }
     }