473,404 Members | 2,174 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,404 software developers and data experts.

Zipping files

Hi

Is there a way in vb.net to zip files?

Thanks

Regards
Apr 27 '07 #1
4 6339
Use SharpZipLib from http://tinyurl.com/yuynd8

GS

"John" <Jo**@nospam.infovis.co.ukwrote in message
news:%2***************@TK2MSFTNGP05.phx.gbl...
Hi

Is there a way in vb.net to zip files?

Thanks

Regards


Apr 28 '07 #2
VB.NET has the GZIPStream class. The method below compresses the IN bytes,
returning the OUT bytes. Note this method is hacked from another method I
have, so I didn't test it. Reversing the operation is also simple, but this
should give you the idea. I think programs like WinZip can read GZip files.
From MSDN:

"This class
represents the gzip data format, which uses an industry standard algorithm
for lossless file compression and decompression. The format includes a
cyclic redundancy check value for detecting data corruption. The gzip data
format uses the same algorithm as the DeflateStream class, but can be
extended to use other compression formats. The format can be readily
implemented in a manner not covered by patents. The format for gzip is
available from the RFC 1952, "GZIP ." This class cannot be used to compress
files larger than 4 GB."

Imports System.IO
Imports System.IO.Compression

Public Sub Compress(ByVal inBytes() As Byte, ByRef outBytes() As Byte)

Dim theGZIPStream As GZipStream = Nothing
If inBytes.Length < 1 Then
Throw New ArgumentException("inBytes.length < 1")
End If
Using theMemoryStream As New MemoryStream()

theGZIPStream = New GZipStream(theMemoryStream,
CompressionMode.Compress)
theGZIPStream.Write(m_Bytes, 0, inBytes.Length)

outBytes = theMemoryStream.ToArray()

End Using

End Sub
Apr 28 '07 #3
"John" <Jo**@nospam.infovis.co.ukschrieb:
Is there a way in vb.net to zip files?
..NET System.IO.Compression and zip files
<URL:http://blogs.msdn.com/dotnetinterop/archive/2006/04/05/567402.aspx>

Using GZipStream for Compression in .NET [Brian Grunkemeyer]
<URL:http://blogs.msdn.com/bclteam/archive/2005/06/15/429542.aspx>

ZipPackage Class
<URL:http://msdn2.microsoft.com/en-us/library/system.io.packaging.zippackage.aspx>

Compressing files and data
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=compression&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Apr 28 '07 #4
I guess, files zipped with gzipstream can be decompressed by winzip but reverse is not true.
And gzipstream few limitations to zip multiple files at a time, which winzip does.
May 6 '07 #5

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

Similar topics

2
by: Arthur | last post by:
Does anyone know if the new Windows 2003 built-in .zip compressor/decompressor is available to scripting? If so, can you kindly point me in the right direction? I've searched and searched MSDN...
2
by: Beau | last post by:
Is there a native 'zipping' or compression compoonent in windows accessable via ASP? Or do you have to buy a compoonent?
0
by: Benjamin Bittner | last post by:
hallo ng, first of all, for the zipping progress i use the ziplib from http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx now to my problem. im trying to build a little application...
1
by: RJN | last post by:
Hi Does .Net provide libraries for zipping files? I read that a third party component CSharplib is available for doing this. Is there any license restriction for using this? Thanks rjn
9
by: ReidarT | last post by:
How can I zip (compress) a file in vs2005 with windows own zip-program? reidarT
6
by: reidarT | last post by:
I will develop a backup routine with local files (zipped) to an internet server via ftp. How do I zip files in Vb.net? reidarT
7
by: Dylan Parry | last post by:
Hi folks, I've got a page that outputs XML, but in some cases the size of the page is several MB. So I figured the best way to deal with it is to ZIP the contents of the page and send that to...
1
by: durumdara | last post by:
Hi! As I experienced in the year 2006, the Python's zip module is not unicode-safe. With the hungarian filenames I got wrong result. I need to convert iso-8859-2 to cp852 chset to get good...
2
by: karen.google | last post by:
I have an SSIS package that I'm converting from DTS (SQLServer 2005), and the ActiveX Script Task (in VBScript) is deprecated, so I'm trying to convert things to Script tasks (in VB .net). I...
2
by: Alien | last post by:
Hi, I am fairly new to PHP and wondering if there if PHP has any library that does zipping of files. Cheers.
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.