473,797 Members | 2,955 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Zipping files

Hi

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

Thanks

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

GS

"John" <Jo**@nospam.in fovis.co.ukwrot e in message
news:%2******** *******@TK2MSFT NGP05.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.Compr ession

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

Dim theGZIPStream As GZipStream = Nothing
If inBytes.Length < 1 Then
Throw New ArgumentExcepti on("inBytes.len gth < 1")
End If
Using theMemoryStream As New MemoryStream()

theGZIPStream = New GZipStream(theM emoryStream,
CompressionMode .Compress)
theGZIPStream.W rite(m_Bytes, 0, inBytes.Length)

outBytes = theMemoryStream .ToArray()

End Using

End Sub
Apr 28 '07 #3
"John" <Jo**@nospam.in fovis.co.ukschr ieb:
Is there a way in vb.net to zip files?
..NET System.IO.Compr ession 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.packa ging.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
2275
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 and can't find a damn thing. TIA. Arthur
2
1424
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
1173
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 for zipping our webservers logfiles. after zipping all files, i've tried to delete all files, but i couldnt. i got an error message that i cannot delete a file, because it is still in use. Here my two functions for that:
1
431
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
5515
by: ReidarT | last post by:
How can I zip (compress) a file in vs2005 with windows own zip-program? reidarT
6
5040
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
1575
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 the browser along with the appropriate headers. So my question... Is there a way that I can create a ZIP file containing an XML document based on the value of a string/XmlDocument object? If not, is there a way of temporarily writing out an...
1
1510
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 result. As I see, this module is "a command line tool" imported as extension. Now I search for something that can handle the characters good, or handle the unicode filenames.
2
3797
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 have a script that is zipping up some files, and it's using an old Winzip, which I don't have on my pc, and certainly wouldn't have on the server, once I got the code over there. So, I wanted to use the built-in zip function for XP. If, in Windows...
2
1440
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.
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9536
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10245
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10205
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10021
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9063
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6802
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5458
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4131
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.