Hello friends,
Below is the code to unzip a zip file . However , problem occurs when there is a zip file within that zip file...please tell me how to do that? ie..unzip a file withing a zip file too...??

private void btnok_Click(object sender, EventArgs e)
        {
            FastZip zp = new FastZip();
            zp.ExtractZip(txtpath.Text, txtdestination.Text, "");
            MessageBox.Show("Folder Unzipped Successfully");
        
                    }

CYA
Rohan

The contents of the zipfile is placed in the targetfolder. You can use DirectoryInfo.GetFiles() to process each file in the targetdir and extract them afterwards if you want.

Another option would be to use the FastZip(FastZipEvents) to create the new instance so you get notified of each individual file that is being unpacked. When you unpack another zipfile, you can respond to that on the spot.

Sorry I cannot give you any code. I don't have the lib installed.

Can't v use a loop that iterates within those line of code n the code keeps on unzipping the files ? eg :
for this code:

private void btnok_Click(object sender, EventArgs e)
      {
        FastZip zp = new FastZip();
        zp.ExtractZip(txtpath.Text, txtdestination.Text, "");
        MessageBox.Show("Folder Unzipped Successfully");

                }

can't v use the loop so that this piece of code keeps on repeating n unzipping all zip files...ne idea how to write the loop code?

cya
Rohan

The contents of the zipfile is placed in the targetfolder. You can use DirectoryInfo.GetFiles() to process each file in the targetdir and extract them afterwards if you want.

Another option would be to use the FastZip(FastZipEvents) to create the new instance so you get notified of each individual file that is being unpacked. When you unpack another zipfile, you can respond to that on the spot.

Sorry I cannot give you any code. I don't have the lib installed.

Edited 3 Years Ago by Reverend Jim: Fixed formatting

you can try something like this:

bool isToZip=true
String sourceFileName="file name";
String destinationFile="destination file name";
while(isToZip)
{
      //1.un zip source file to destinaion file, i.e. sourceFileName
      //2. get destination file,i. e. destinationFile
      //3. if destination file is ziped one, sourceFileName=destinationFile
     //4. give new destinationFile
}

i have just given a hint, it should work

okie...ll try n let u know...

cya
Rohan

you can try something like this:

bool isToZip=true
String sourceFileName="file name";
String destinationFile="destination file name";
while(isToZip)
{
      //1.un zip source file to destinaion file, i.e. sourceFileName
      //2. get destination file,i. e. destinationFile
      //3. if destination file is ziped one, sourceFileName=destinationFile
     //4. give new destinationFile
}

i have just given a hint, it should work

nah ...am not getting desired output.

Okie...Let me put my problem in front of all of u once again :

I am doing an application(Windows) using C#.net wherein i need to unzip a particular file
and list the contents of that zip n its working properly. However problem arises when there are
zip files within that Unzipped Zip file....( read it slowly so u ll get wht am saying....)

Say if i unzip a file name Myfile.zip , My Listbox lists More 10 zip files contend in this
folder which i what i dont want....i want my Listbox to list the files in these zip files
also...How can i do that ?In short , My all zip files should be unzipped.

For this :
i have downloaded ICSharp.zip dll n am using it. Here is my code for the same....
but how my problem can be solved ? Pl...help me understand...Code help will be
appreciated...
thanks in advance

using ICSharpCode.SharpZipLib.Zip;

 private void btnok_Click(object sender, EventArgs e)
        {
              FastZip zp = new FastZip();
              string fname = (txtpath.Text.Substring(txtpath.Text.LastIndexOf("\\") + 1));
              zp.ExtractZip(fname,txtdestination.Text,".Zip");
           }

CYA
Rohan

okie...ll try n let u know...

cya
Rohan

This article has been dead for over six months. Start a new discussion instead.