shawnlehner
asked on
simple SharpZipLib unzip function
I need a simple function using the free SharpZipLib.dll that does the following.
Unzips a single file at a time from the archive (looping through each file unzipping one at a time) so that I can run a function on each file as it is decompressed.
Unzips a single file at a time from the archive (looping through each file unzipping one at a time) so that I can run a function on each file as it is decompressed.
ASKER
dont know that much C... could somone convert this to vb.net?
Thanks Much.
Thanks Much.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Greg
public void Extract(string _filename, string _targetDir) {
ZipInputStream zipStream = null;
try {
this.OnProcessMessage(this
zipStream = new ZipInputStream(File.OpenRe
ZipEntry theEntry;
while ((theEntry = zipStream.GetNextEntry()) != null) {
Console.WriteLine(theEntry
string directoryName = Path.GetDirectoryName(theE
string fileName = Path.GetFileName(theEntry.
// create directory
string cdir = Directory.GetCurrentDirect
Directory.SetCurrentDirect
Directory.CreateDirectory(
if (fileName != String.Empty) {
this.OnProcessMessage(this
FileStream streamWriter = File.Create(theEntry.Name)
int size = 2048;
byte[] data = new byte[2048];
while (true) {
size = zipStream.Read(data, 0, data.Length);
if (size > 0) {
streamWriter.Write(data, 0, size);
} else {
break;
}
}
streamWriter.Close();
}
Directory.SetCurrentDirect
}
}
catch(System.Exception ex) {
throw new Exception("Unable to Extract Zip!",ex) ;
}
finally {
zipStream.Close();
this.OnProcessMessage(this
File.Delete(_filename) ;
}
}