Connecting Tech Pros Worldwide Forums | Help | Site Map

UNZIP File

Chris
Guest
 
Posts: n/a
#1: Jul 21 '05
Hi
Where can I find info on unzipping file with VB.NET. I need to unzip a winzip file with my application

Thanks

phoenix
Guest
 
Posts: n/a
#2: Jul 21 '05

re: UNZIP File


The J# runtimes have that capability and otherwise check out
http://www.icsharpcode.net/OpenSourc...b/Default.aspx for a free
zipping utility.

Yves

"Chris" <anonymous@discussions.microsoft.com> schreef in bericht
news:5B7AB82B-965F-45B3-B187-77F80BB85BDA@microsoft.com...[color=blue]
> Hi,
> Where can I find info on unzipping file with VB.NET. I need to unzip a[/color]
winzip file with my application.[color=blue]
>
> Thanks[/color]


Chris
Guest
 
Posts: n/a
#3: Jul 21 '05

re: UNZIP File


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(

---------------------------------------------------
The zip file is created but when I try to open it I get "File is not a valid archive" and ideas?
Jon Skeet [C# MVP]
Guest
 
Posts: n/a
#4: Jul 21 '05

re: UNZIP File


Chris <anonymous@discussions.microsoft.com> wrote:[color=blue]
> The zip file is created but when I try to open it I get "File is not
> a valid archive" and ideas?[/color]

I don't believe that bzip2 is the same as zip.

See http://www.pobox.com/~skeet/csharp/faq/#zip though for a link to a
..NET zip library.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Chris
Guest
 
Posts: n/a
#5: Jul 21 '05

re: UNZIP File


Jon
Thhats the same lib I downloaded but I can't seem to unzip a .zip file. Do you have any ideas?
Jon Skeet [C# MVP]
Guest
 
Posts: n/a
#6: Jul 21 '05

re: UNZIP File


Chris <anonymous@discussions.microsoft.com> wrote:[color=blue]
> Thhats the same lib I downloaded but I can't seem to unzip a .zip
> file. Do you have any ideas?[/color]

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();
}
}
}


--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jon Skeet [C# MVP]
Guest
 
Posts: n/a
#7: Jul 21 '05

re: UNZIP File


Chris <anonymous@discussions.microsoft.com> wrote:[color=blue]
> Thanks Guy! But I truely don't understand C#.[/color]

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.)

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Cor
Guest
 
Posts: n/a
#8: Jul 21 '05

re: UNZIP File


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


Closed Thread


Similar .NET Framework bytes