Hi Guys,
I am unzipping a folder into a new folder and then wants to read all the files from the folder .My code is as follows.I dont want to create a folder but i cnt figure out a way to read all the files froma compressed folder and now when i create another folder i cnt read the files and i get error saying i do not have persmission to access teh folder.I have unchecked the read only preperty of the folder too.Can anyone help me with this.

private void button1_Click(object sender, EventArgs e)
        {


            OpenFileDialog op = new OpenFileDialog();
            //DialogResult ok1 = dlgFolder.ShowDialog();
            //op.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
            List<string> lst2 = new List<string>();
            //if (ok1 != DialogResult.Cancel)
            if (op.ShowDialog() != DialogResult.Cancel)
            {

                Title title1 = new Title();
                using (ZipFile zfile = new ZipFile())
                {

                    string path1 = op.FileName;
                    string newpath = "c:/processed/Procc1";
                    // using(var zf = Ionic.Zip.ZipFile.Read(path1))

                    using (ZipFile zip = ZipFile.Read(path1))
                    {


                        zip.ExtractAll(newpath);
                       
                        StreamReader read = new StreamReader(newpath);

Look in the System.IO namespace.
Especially System.IO.File and System.IO.Directory.
These are used to inspect the file system.

I am unzipping a folder into a new folder and then wants to read all the files from the folder .My code is as follows.I dont want to create a folder but i cnt figure out a way to read all the files froma compressed folder and now when i create another folder i cnt read the files and i get error saying i do not have persmission to access teh folder.I have unchecked the read only preperty of the folder too.Can anyone help me with this.

If I read you right, you want to get at the contents of a ZIP file (compressed folder) without extracting them first. Yes? If so, you might look into using SharpZipLib.

Looking at the DetNetZip Library Examples you probably want to do something like this.

// open zip file given in OpenFileDialog
  using (ZipFile zip = ZipFile.Read(op.FileName))
  {
    foreach (ZipEntry e in zip)
    {
      MemoryStream outputStream = new MemoryStream();
      e.Extract(outputStream); // write file contents to memory stream
      outputStream.Position = 0; // reset stream pointer to start
      // do what you want with the stream data.
    }
  }

[Edit] Thanks to both sadhawan and gusano79 for introducing me to these Zip libraries.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.