473,394 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

unzipping files

134 100+
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:
Expand|Select|Wrap|Line Numbers
  1. string dirpath = sfd.FileName;
  2.                 DirectoryInfo di = new DirectoryInfo(dirpath);
  3.  
  4.                 foreach(FileInfo fi in di.GetFiles("MyProgram.zip"))
  5.                 {
  6.                     Decompress(fi);
  7.                 }
This is the unzip proces itself:
Expand|Select|Wrap|Line Numbers
  1.             using (FileStream inFile = fi.OpenRead())
  2.             {
  3.                 string curFile = fi.FullName;
  4.                 string origName = curFile.Remove(curFile.Length - fi.Extension.Length);
  5.  
  6.                 using (FileStream outFile = File.Create(origName))
  7.                 {
  8.                     using (GZipStream Decompress = new GZipStream(inFile,CompressionMode.Decompress))
  9.                     {
  10.                         Decompress.CopyTo(outFile);
  11.                     }
  12.                 }
  13.             }
Feb 27 '12 #1
3 1034
Can you add the actual error message please?
Feb 28 '12 #2
michaeldebruin
134 100+
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.
Feb 28 '12 #3
Do you know on which line it fails?

if not, change your code to this:
Expand|Select|Wrap|Line Numbers
  1.     string dirpath = sfd.FileName;
  2.     System.Console.WriteLine("DirPath = " + dirpath);
  3.     DirectoryInfo di = new DirectoryInfo(dirpath);
  4.     System.Console.WriteLine("DirInfo Created");
  5.     foreach(FileInfo fi in di.GetFiles("MyProgram.zip"))
  6.     {
  7.         System.Console.WriteLine("Decompressing " + fi.Name);
  8.         Decompress(fi);
  9.         System.Console.WriteLine("Decompress Complete")
  10.     }
  11.  
And then post the console window in code tags.
Feb 28 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Doug Tolton | last post by:
Is there a simple way to zip and unzip files? I'm looking for something along the lines of: zfile = zipfile(r'c:\somefile.zip') zfile.extract(r'c:\somefiles') I've looked at the...
1
by: Greg Lindstrom | last post by:
Hello- I am trying to read a file from a zip archive. I have read the documentation on zipfile and can read the names of the files in the archive and the length of each file, but do not see how...
7
by: Paul Brownjohn | last post by:
Hi Guys I need a dll that just unzips zipped files...does anyone know of a freeware or cheapo shareware one that does this. I know there are quite a lot of rather sophisticated ones out there...
6
by: JezB | last post by:
From a windows application, I want to provide an "archive" facility which will scan a specific directory and put specific files into some single "Archive file", a bit like a zip-file I guess, but...
7
by: thewhoracle | last post by:
I have a C# application that essentially builds batch and text files and runs them from the command line, but i need to unzip something from the command line. What i need is either an unzipping...
0
by: stjulian | last post by:
On Windows Server 2003, IIS 6 I am looking for an unzipping component. I have a series of files that are available zipped at a considerable decrease in size. And before ASPINET fails on a script...
12
by: =?Utf-8?B?am9uaWdy?= | last post by:
I wrote a simple VB.NET application that imports and edits CSV files. Now I’d like to “lock” the raw (pre-import) CSV files so these cannot be opened separately. It is not high-sensitive...
2
by: puneetshadija | last post by:
Hello everyone, I want to zip all the files in a folder in an web application, can you suggest me, so as to how can this be done. I did refer to an article posted in Code Project, but its...
0
by: avik1612 | last post by:
Hi, I have created a program to unzip the file. It is unzipping the zip files when put in directory i.e folder inside folder but when i create a zip file without putting in a folder and try to...
1
by: kss | last post by:
Hey all, I am new to python and I need to unzip a zip file which is password protected. I tried using zipfile class. Aparently, when i try doing a zip.read(filename), it throws an exception stating...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.