UNZIP File

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
Where can I find info on unzipping file with VB.NET. I need to unzip a winzip file with my application

Thanks
 
Hi
I have th foll code

If (False = rdCompress.Checked) The
' Decompression of single-file archiv
Dim fsBZ2Archive As FileStream, fsOutput As FileStrea
Dim strOutputFilename As Strin

fsBZ2Archive = File.OpenRead(txtFileName.Text
strOutputFilename = Path.GetDirectoryName(txtFileName.Text) &
Path.GetFileNameWithoutExtension(txtFileName.Text

fsOutput = File.Create(strOutputFilename

BZip2.Decompress(fsBZ2Archive, fsOutput

fsBZ2Archive.Close(
fsOutput.Flush(
fsOutput.Close(
Els
'Compression of single-file archiv
Dim fsInputFile As FileStream, fsBZ2Archive As FileStrea
fsInputFile = File.OpenRead(txtFileName.Text
fsBZ2Archive = File.Create(txtFileName.Text + ".zip") '<<<<<<<<<<<<<i change this from .BZ to .ZI

BZip2.Compress(fsInputFile, fsBZ2Archive, 4026

fsInputFile.Close(
 
Jon
Thhats the same lib I downloaded but I can't seem to unzip a .zip file. Do you have any ideas?
 
Chris said:
Thhats the same lib I downloaded but I can't seem to unzip a .zip
file. Do you have any ideas?

Well, using ZipFile, ZipInputStream and ZipEntry seem to be a good bet
to me.

I've just written this code which unzips a file - but it doesn't do
anything about paths etc, so will fail on various zip files. It just
demonstrates the very basic ideas.

using System.IO;
using ICSharpCode.SharpZipLib.Zip;

public class Test
{
static void Main(string[] args)
{
foreach (string x in args)
{
Unzip (x);
}
}

static void Unzip (string zipName)
{
byte[] buffer = new byte[16384];
ZipFile zipFile = new ZipFile(zipName);
try
{
foreach (ZipEntry entry in zipFile)
{
Stream input = zipFile.GetInputStream(entry);
using (Stream output = File.Create(entry.Name))
{
int read;
while((read=input.Read(buffer,0,buffer.Length))>0)
{
output.Write(buffer, 0, read);
}
}
}
}
finally
{
zipFile.Close();
}
}
}
 
Chris said:
Thanks Guy! But I truely don't understand C#.

It should be fairly clear what method calls are involved though. The
only other thing you need to know is that a "using" construct calls
Dispose on what you create at the start of it.

There should certainly be enough information there for you to work out
how to use the library. (There should be enough in the documentation,
even - I hadn't used SharpZipLib at all before creating that test app,
and it only took a few minutes or so to write it.)
 
Hi Jon,

Chriss asked this question again in the language.vb group.

I have given hime the bottle opener with a lot of links to C#, VB
converters.

Cor
 
Back
Top