Last post Sep 10, 2010 09:01 AM by honzas
Aug 12, 2010 07:06 AM|Rapido_XS|LINK
I'm currently sitting with a solution that requires 'Zipping' a file. There are many solutions using Java or C# code, but none I can implement using the server I'm working with so it needs to be done in VB.
Any answers will be greatly appriciated.
Aug 12, 2010 08:36 AM|marcinsw|LINK
VB and C# are equivalent, everything that can be written in c# can be written in VB too. Good news is also that you can directly convert C# to VB with this tool:
Here is a simple method that compress a file and use no external libraries:
public static void GZipCompression(string input, string output)
FileStream fs = new FileStream(input, FileMode.Open, FileAccess.Read, FileShare.Read);
byte data = new byte[fs.Length];
fs.Read(data, 0, data.Length);
FileStream compressed = new FileStream(output, FileMode.OpenOrCreate, FileAccess.ReadWrite);
GZipStream gzip = new GZipStream(compressed, CompressionMode.Compress, false);
gzip.Write(data, 0, data.Length);
Just pass correct paths using Server.MapPath().
Hope it helps...
Aug 12, 2010 08:38 AM|ignatandrei|LINK
You can use this component (source in C#, but you can add as a reference the dll)
or , for native GZip, you can use
Aug 12, 2010 08:58 AM|vinay13mar|LINK
plz check the link
Sep 10, 2010 09:01 AM|honzas|LINK
If you reference a binary .NET library, it does not matter whether it has been compiled from C#, VB or another .NET language.
For example our component
Rebex.ZIP is written in C#, but all samples and tutorials are published both in C# and VB.NET.
Your question - zipping some files, would be solved by following two lines of code:
(taken from tutorial page
Imports Rebex.IO.Compression' add all *.TXT files from the local directory C:\Data\
' to the directory \Data-2010 (within the Zip file)
' (ZIP archive C:\archive.zip doesn't have to exist)
ZipArchive.Add("C:\archive.zip", "C:\Data\*.txt", "\Data-2010")
The code need to reference .DLL which can be