0

How can i get the content names of a zipped folder in C# i.e. name of files and folders inside the compressed folder? I want to decompress the zip by using GZipStream only.

thanks, kapil

Jaqen H'ghar
  • 1,839
  • 7
  • 37
  • 66

1 Answers1

0

You can't do this using GZipStream only. You will need an implementation of the ZIP standard such as #ziplib. Quote from MSDN:

Compressed GZipStream objects written to a file with an extension of .gz can be decompressed using many common compression tools; however, this class does not inherently provide functionality for adding files to or extracting files from .zip archives.

Example with #ziplib:

using (var stream = File.OpenRead("test.zip"))
using (var zipStream = new ZipInputStream(stream))
{
    ZipEntry entry;
    while ((entry = zipStream.GetNextEntry()) != null)
    {
        // entry.IsDirectory, entry.IsFile, ...
        Console.WriteLine(entry.Name);
    }
}
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928