PKZIP - PK Ware - .NET Example

G

Guest

Hi,
My project requirement is to use the PKZip/PkWare compression/de-compression
methods for files.

Can any one of you, pls help me in getting the .net code example (links)
for implementing the same.

Thanks in advance for your help.

With best Regards,
Ravikanth Chikka
mail: (e-mail address removed)
 
J

Jordan

Try
http://www.7-zip.org/

Their sourceforge page: http://sourceforge.net/projects/sevenzip/

I have done extensive research in trying to find a reliable and compact zip
utility I could call from the command line, and 7-zip is the best I found.
The 7-zip utility comes in two versions - one with a GUI and another super
small command line version (< 500K in size) that you can call from your .NET
code (see sample code below). It will zip according to variety of popular
zip algorithms, and performs very well... and it's free.

This source code loops through a folder, looking for files with a ".BAK"
extension and zips them into another folder:
/*-------------------------------------------------------------------------------------------------------------------
* This routine calls 7za.exe which is a free but robust
command-line zip utility.
* For more info: http://www.7-zip.org/
* 7za.exe is a stand-alone and very small utility exe. It does not need to
be installed or registered.
* Just copy it to the destination machine and call it from a command line
or batch file like this:
* "C:\SomeFolder\7za.exe" a -tzip
c:\ziptest\NewZipFile.zip c:\ziptest\ZipThisFile.txt
*-------------------------------------------------------------------------------------------------------------------*/pathToSQLBackupsIN = sourceDriveLetter + pathToSQLBackupsIN;pathToSQLBackupsOUT = sourceDriveLetter + pathToSQLBackupsOUT;string zipMessage = "";string curBakFile = ""; string curZipFile = "";string[] bakFileList;bakFileList = Directory.GetFiles(pathToSQLBackupsIN + "\\", "*.BAK");Log (bakFileList.Length.ToString() + " .BAK file(s) found.",pathToSQLBackupsIN + "\\*.BAK", w);if (bakFileList.Length > 0) { int zipCounter = 0; System.Collections.IEnumerator enumBakFiles = bakFileList.GetEnumerator(); while (enumBakFiles.MoveNext()) { FileInfo fiBAK = new FileInfo(enumBakFiles.Current.ToString()); curBakFile = pathToSQLBackupsIN + "\\" + fiBAK.Name; curZipFile = pathToSQLBackupsOUT + "\\" + fiBAK.Name.Replace(".BAK",".zip"); ProcessStartInfo pInfoZip = new ProcessStartInfo(); pInfoZip.FileName = currentWorkingDirectory + @"\7za.exe"; pInfoZip.Arguments = (@"a -tzip " + curZipFile + " " + curBakFile); Process pZip = Process.Start(pInfoZip); //Wait up to 20 seconds for the process to end. pZip.WaitForExit(20000); pZip.Close(); pZip.Dispose(); System.Threading.Thread.Sleep(pauseDuration); // delete the original backup file if the zip was created if (File.Exists(curZipFile)) { FileInfo fi = new FileInfo(curZipFile); if (fi.Length > 100) { // Only proceed if the zip file is larger than zero (larger than someminimal/reasonably expected size). If it's not, it's not been created. File.Delete(curBakFile); zipCounter += 1; zipMessage = zipCounter.ToString() + " Zip-OK"; } } } // end loop through bak files}else { zipMessage = "NO BAKs found";}-HTH"RaviChikka" <[email protected]> wrote in messagenews:[email protected]...> Hi,> My project requirement is to use the PKZip/PkWarecompression/de-compression> methods for files.>> Can any one of you, pls help me in getting the .net code example (links)> for implementing the same.>> Thanks in advance for your help.>> With best Regards,> Ravikanth Chikka> mail: (e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top