473,396 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

unzip using SharpZipLib

Hi

I am using SharpZipLib. Could someone help with some sample code to unzip a file to a specified location.

Thanks
--------------------------------
From: Aji Mathews

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>VvXeqg2VFkmm0K5qb1dBJg==</Id>
Nov 21 '05 #1
1 10130

This uses the ZipInputStream method which provides sequential access
to each entry. The ZipFile method provides random access to each
entry.

The help files have lots of good examples too. They're C# but the
code is very similar to VB.NET.

Note that this was just test code I put together to verify the
decryption functionality since some people reported problems. This is
not really production quality in that it doesn't use try/finally to
ensure all of the streams are properly closed.

HTH,

Sam
Imports System.IO
Imports ICSharpCode.SharpZipLib.Zip

Module Module1

Sub Main()
Dim fileName As String = Path.GetFullPath("../AcapCopy.zip")
Dim destPath As String = Path.GetFullPath("../Unzipped/")

If Not Directory.Exists(destPath) Then
Directory.CreateDirectory(destPath)
Else
For Each s As String In Directory.GetFiles(destPath)
File.Delete(s)
Next
End If

Dim inStream As New ZipInputStream(File.OpenRead(fileName))
Dim outStream As FileStream

Dim entry As ZipEntry
Dim buff(2047) As Byte
Dim bytes As Integer

Do While True
entry = inStream.GetNextEntry()

If entry Is Nothing Then
Exit Do
End If

outStream = File.Create(destPath + entry.Name, 2048)

Do While True
bytes = inStream.Read(buff, 0, 2048)
If bytes = 0 Then
Exit Do
End If

outStream.Write(buff, 0, bytes)
Loop

outStream.Close()
Loop

inStream.Close()

End Sub

End Module
On Wed, 16 Mar 2005 21:07:09 -0800, Aji Mathews via .NET 247
<an*******@dotnet247.com> wrote:
Hi

I am using SharpZipLib. Could someone help with some sample code to unzip a file to a specified location.

Thanks
--------------------------------
From: Aji Mathews

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>VvXeqg2VFkmm0K5qb1dBJg==</Id>


B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Chris | last post by:
Hi Where can I find info on unzipping file with VB.NET. I need to unzip a winzip file with my application Thanks
1
by: jeff | last post by:
hi, alls Is there method to support ZIP/UNZIP in VS.NET 2003 Which name space can be used? Is there any smaple? Thanks
10
by: Yogi_Bear_79 | last post by:
pardon my ignorance as I am a self-taught hobbyist programmer. I am curious after reading up on SharpZipLib. Can I embed a zipped txt file in my program? Then either read from within the zip...
3
by: jyoti.khera | last post by:
Hi, Can anyone tell me if there is any inbuilt utility in windows shell API with the help of which we can Unzip the files. I need to use that and Unzip the files using c# code. Regards Jyoti
1
by: ACaunter | last post by:
can someone please help me try to unzip a folder automatically within an asp.net program... thanks -- AdamPC@hotmail.com
7
by: italo | last post by:
Greetings. There is a way to zip and unzip files. its like a Winzip or WinRar or PowerArchiver.. but i need to .NET ZIP and unZIP these files. ex. <name_of_file>.zip i dont know if theses...
3
by: SDRoy | last post by:
Hello Can someone tell me how I can unzip a .zip file in C#. The zip file is already there and I just need to unzip..not zip and unzip. -- Thanks, SDRoy
13
by: fniles | last post by:
In VB.NET 2003 how can you programmatically unzip a ZIP file ? Thank you.
5
by: =?Utf-8?B?anVsaW8=?= | last post by:
Hi, I write a program to unzip a Tar file generated on a Unix environment file using SharpZipLib, but returns a error "Header checksum is invalid" when execute the program. This error appears...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.