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
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
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);
}
}