C# unzipping .ZIP files

W

William S

Hello

Anyone have any exeriance using C# and pkunzip? I'm writing up a C# app
that may have to extract files from a .ZIP archieve. The files will be
zipped up, and I'll need to unzip hem and put them in the path there are
zipped up in. My question how can i do that, or is it possiable?
 
M

Marty Honea

I've not had to do it in C# yet, but I've used this product in the past with
Clarion.

http://www.lindersoft.com/products_lszip.htm

Friedrich Linder writes some fantastic stuff, and is very responsive when
asked questions. I wouldn't hesitate to use anything he wrote.

He says on his website this works with C++, so if he doesn't have a C#
version you could still use it with InteropServices.

Marty
 
A

Arne Vajhøj

William said:
Anyone have any exeriance using C# and pkunzip? I'm writing up a C# app
that may have to extract files from a .ZIP archieve. The files will be
zipped up, and I'll need to unzip hem and put them in the path there are
zipped up in. My question how can i do that, or is it possiable?

You should be able to do that using either the J# lib or
the open source #ZipLib.

I believe I have some examples if you are interested.

Arne
 
J

Jesse Houwing

Hello William,
Hello

Anyone have any exeriance using C# and pkunzip? I'm writing up a C#
app that may have to extract files from a .ZIP archieve. The files
will be zipped up, and I'll need to unzip hem and put them in the path
there are zipped up in. My question how can i do that, or is it
possiable?


have a look at:
http://www.icsharpcode.net/OpenSource/SharpZipLib/

alternatively, you can hook into the J# library which comes with Zip Support
out of the box
http://aspalliance.com/1269_Zip_and_UnZip_files_in_C_using_J_libraries
 
M

Moe Sisko

William S said:
Anyone have any exeriance using C# and pkunzip? I'm writing up a C# app
that may have to extract files from a .ZIP archieve. The files will be
zipped up, and I'll need to unzip hem and put them in the path there are
zipped up in.

I've used this (free) library before without problems :

http://www.codeplex.com/DotNetZip
 
C

Cheeso

What makes it better than the gratis alternatives.

DotNetZip is one of those gratis alternatives for handling ZIP files.
It's a 100% managed code library to read, create, and update zip files
from within any .NET application.
It does zip passwords, zip passwords with AES encryption, ZIP64,
Unicode, self-extracting archives, and more. There's a good help file
with lots of examples (online version here:http://
cheeso.members.winisp.net/DotNetZipHelp/ ). There's also a support
forum on codeplex.

Here's some sample code to extract all files from a zip to a
particular directory, without overwriting existing files:

String TargetDirectory= "c:\\unpack";
using(Ionic.Zip.ZipFile zip= Ionic.Zip.ZipFile.Read
(ZipFileToExtract))
{
zip.ExtractAll(TargetDirectory,
Ionic.Zip.ExtractExistingFileAction.DontOverwrite);
}

Sample to extract entries conditionally, and overwrite any existing
files:

using (var zip1 = Ionic.Zip.ZipFile.Read(zipToUnpack))
{
foreach (var entry in zip1)
{
// extract only the entries I want:
if (wantExtract(entry.FileName))
entry.Extract(dir,
Ionic.Zip.ExtractExistingFileAction.OverwriteSilently);
}
}


Sample code to create a zip file, zipping up a directory:

using (var zip = new Ionic.Zip.ZipFile())
{
zip.AddDirectory(directory, System.IO.Path.GetFileName
(directory));
zip.Save(targetZip);
}

Sample to create a self-extracting archive (SFX):
using (var zip = new Ionic.Zip.ZipFile())
{
zip.AddDirectory(directory, System.IO.Path.GetFileName
(directory));
zip.Comment = "This will be embedded into a self-extracting
console-based exe";
zip.SaveSelfExtractor("archive.exe",
SelfExtractorFlavor.ConsoleApplication);
}

DotNetZip can also produce a Windows GUIs for the SFX.

check it out. http://dotnetzip.codeplex.com.

(DotNetZip is free.)
 
C

Cheeso

What makes it better than the gratis alternatives.

DotNetZip is one of those gratis alternatives for handling ZIP files.
It's a 100% managed code library to read, create, and update zip files
from within any .NET application.
It does zip passwords, zip passwords with AES encryption, ZIP64,
Unicode, self-extracting archives, and more. There's a good help file
with lots of examples (online version here:http://
cheeso.members.winisp.net/DotNetZipHelp/ ). There's also a support
forum on codeplex.

Here's some sample code to extract all files from a zip to a
particular directory, without overwriting existing files:

String TargetDirectory= "c:\\unpack";
using(Ionic.Zip.ZipFile zip= Ionic.Zip.ZipFile.Read
(ZipFileToExtract))
{
zip.ExtractAll(TargetDirectory,
Ionic.Zip.ExtractExistingFileAction.DontOverwrite);
}

Sample to extract entries conditionally, and overwrite any existing
files:

using (var zip1 = Ionic.Zip.ZipFile.Read(zipToUnpack))
{
foreach (var entry in zip1)
{
// extract only the entries I want:
if (wantExtract(entry.FileName))
entry.Extract(dir,
Ionic.Zip.ExtractExistingFileAction.OverwriteSilently);
}
}


Sample code to create a zip file, zipping up a directory:

using (var zip = new Ionic.Zip.ZipFile())
{
zip.AddDirectory(directory, System.IO.Path.GetFileName
(directory));
zip.Save(targetZip);
}

Sample to create a self-extracting archive (SFX):
using (var zip = new Ionic.Zip.ZipFile())
{
zip.AddDirectory(directory, System.IO.Path.GetFileName
(directory));
zip.Comment = "This will be embedded into a self-extracting
console-based exe";
zip.SaveSelfExtractor("archive.exe",
SelfExtractorFlavor.ConsoleApplication);
}

DotNetZip can also produce a Windows GUIs for the SFX.

check it out. http://dotnetzip.codeplex.com.

(DotNetZip is free.)
 

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

Top