unzipping files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • michaeldebruin
    New Member
    • Feb 2011
    • 134

    unzipping files

    Hello all,

    I am trying to create an installer for my program. Which can unzip the folder in which it is downloaded. The Download part works fine. But I am repeatedly getting the error that the my file path is invalid during the unzip proces.

    This is where I am trying to get the unzip method:
    Code:
    string dirpath = sfd.FileName;
                    DirectoryInfo di = new DirectoryInfo(dirpath);
    
                    foreach(FileInfo fi in di.GetFiles("MyProgram.zip"))
                    {
                        Decompress(fi);
                    }
    This is the unzip proces itself:
    Code:
                using (FileStream inFile = fi.OpenRead())
                {
                    string curFile = fi.FullName;
                    string origName = curFile.Remove(curFile.Length - fi.Extension.Length);
    
                    using (FileStream outFile = File.Create(origName))
                    {
                        using (GZipStream Decompress = new GZipStream(inFile,CompressionMode.Decompress))
                        {
                            Decompress.CopyTo(outFile);
                        }
                    }
                }
  • Samuel Jones
    New Member
    • Jan 2011
    • 48

    #2
    Can you add the actual error message please?

    Comment

    • michaeldebruin
      New Member
      • Feb 2011
      • 134

      #3
      I haven't changed anything, but now it says "The Directoryname is invalid". This error appears when the download is ready and I am trying to upzip the file. Visual Studio doesn't give any errors while building the program.

      Comment

      • Samuel Jones
        New Member
        • Jan 2011
        • 48

        #4
        Do you know on which line it fails?

        if not, change your code to this:
        Code:
            string dirpath = sfd.FileName;
            System.Console.WriteLine("DirPath = " + dirpath);
            DirectoryInfo di = new DirectoryInfo(dirpath);
            System.Console.WriteLine("DirInfo Created");
            foreach(FileInfo fi in di.GetFiles("MyProgram.zip"))
            {
                System.Console.WriteLine("Decompressing " + fi.Name);
                Decompress(fi);
                System.Console.WriteLine("Decompress Complete")
            }
        And then post the console window in code tags.

        Comment

        Working...