Using GzipStream to open a .zip file which contains mutiple files.

Feb 20 2009 9:49 AM
I have Issue while opening a .zip file which contains multiple files in it.

When I need to open a zip file which having only one file in it, then here the code for it:

FilePath takes the file with .zip extension
[code]
FileStream fileStream = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
GZipStream gZipStream = new GZipStream(fileStream, CompressionMode.Decompress);
StreamReader unzipFileReader = new StreamReader(gZipStream);
[\code]              

This code perfect works fine to open a .zip file which contains only one file in it, and reading it through a StreamReader.

But the issue is, I am having multiple log files are of different type. Some are of .zip extension, which contains single file or multiple files in it.

example:

templog.zip
  - log1.txt
  - log2.txt
  - log3.txt

So I need to decompress the .zip file,  then I need to read all the files in zip file through streamReader.
It shouldn't create a directory and extract the files as if winrar, or winzip does.

Could someone help me out this issue..
If possible please provide me a some sample code or references.

Thanks in Advance

Answers (3)