Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I use .NET to zip/compress folders/files? 1

Status
Not open for further replies.

mbutch

Programmer
Nov 17, 2000
100
US
I want to write a program or service that I can schedule to zip up a folder with a bunch of files, copy it to another location and then unzip them. The file copy isn't a problem, but I haven't found anything to zip or compress a folder.

Thanks
 
I use something like this

Process unzip = new Process();
unzip.StartInfo.FileName = "C:\\gzip.exe";
unzip.StartInfo.Arguments = "-d C:\\file.gz"; '-d for decompress
unzip.Start();
unzip.WaitForExit();
int UnzipInfo = unzip.ExitCode;

gzip.exe doesn't compress folders only files, but maybe winzip32.exe does, you should give it a try
 
Thanks a lot. This method works great. WinZip has a command line add-in that you can download from their site. To zip you use WZZIP.EXE and WZUNZIP.EXE to unzip.
 
FYI -- There is an article in next month's MSDN magazine about using J#'s compression library in C#. No need to call out to an external program.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top