3
Answers

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

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)

0
Photo of Ryan Alford
NA 2.3k 891.7k 16y
Instead of using the "Browse" tab, use the "Project" tab to add a reference.
0
Photo of Stefan
NA 624 0 16y
You don't have to have both in the solution explorer. Open the main project you will be using. In the solution explorer, right-click the references folder. Click "Add Reference...". In the pop up, select the browse tab. Browse the project folder of the project you want to call from. Go to the debug folder and select the .exe or .dll of your project. Select "OK". You should now see the name of that project in your references folder. Add it to your namespaces (i.e. "using MyProject"). Now simply call the method the way you normally would (i.e. "MyProject.Class1.Method1();").

Alternatively, Visual Studio has an option to add a project to your current solution.

Hope this helps!