By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 918 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

UNZIP File

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

Thanks
Jul 21 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
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" <an*******@discussions.microsoft.com> schreef in bericht
news:5B**********************************@microsof t.com...
Hi,
Where can I find info on unzipping file with VB.NET. I need to unzip a winzip file with my application.
Thanks

Jul 21 '05 #2

P: n/a
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?
Jul 21 '05 #3

P: n/a
Chris <an*******@discussions.microsoft.com> wrote:
The zip file is created but when I try to open it I get "File is not
a valid archive" and ideas?


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 - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4

P: n/a
Jon
Thhats the same lib I downloaded but I can't seem to unzip a .zip file. Do you have any ideas?
Jul 21 '05 #5

P: n/a
Chris <an*******@discussions.microsoft.com> wrote:
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();
}
}
}
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #6

P: n/a
Chris <an*******@discussions.microsoft.com> wrote:
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.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #7

P: n/a
Cor
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
Jul 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.