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

Is DeflateStream = .zip format?

Trying to zip/unzip files from VB.NET 2005 with 2.0 .NET Framework ...
but the file created "SampleFile.zip" is not a readable zip file.
(Using GZipStream works correctly to produce a readable .gz file)
How do I properly create a .zip file without 3rd-party lib?

Dim sourceFile As FileStream =
File.OpenRead("c:\temp\SampleFile.chm")
Dim destFile As FileStream =
File.Create("c:\temp\SampleFile.zip")

'wrap dest stream with compression stream
Dim compStream As New DeflateStream(destFile,
CompressionMode.Compress)

'copy data from source stream to destination stream
Dim theByte As Integer = sourceFile.ReadByte()
While theByte <-1
compStream.WriteByte(CType(theByte, Byte))
theByte = sourceFile.ReadByte()
End While
compStream.Flush()

'clean up
sourceFile.Close()
compStream.Close()
destFile.Close()
Jan 31 '08 #1
4 4467
Grok wrote:
Trying to zip/unzip files from VB.NET 2005 with 2.0 .NET Framework ...
but the file created "SampleFile.zip" is not a readable zip file.
(Using GZipStream works correctly to produce a readable .gz file)
How do I properly create a .zip file without 3rd-party lib?
It sounds like what you're after is a zip /archive/ rather than a single
file stored with compression; what do you have against third-party
libraries? For example, SharpZipLib is free and easy to use. Even paying for
one is likely to be cheaper than developing your own.

If you do want to write your own, you can find file formats at
www.wotsit.org.

Andrew
Jan 31 '08 #2
"Grok" <gr**@valhallalegends.comschrieb:
Trying to zip/unzip files from VB.NET 2005 with 2.0 .NET Framework ...
but the file created "SampleFile.zip" is not a readable zip file.
A ZIP file is more than a compressed stream.

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://dotnet.mvps.org/dotnet/faqs/>
Jan 31 '08 #3
On Thu, 31 Jan 2008 15:13:35 +0100, "Herfried K. Wagner [MVP]"
<hi***************@gmx.atwrote:
>"Grok" <gr**@valhallalegends.comschrieb:
>Trying to zip/unzip files from VB.NET 2005 with 2.0 .NET Framework ...
but the file created "SampleFile.zip" is not a readable zip file.

A ZIP file is more than a compressed stream.

Compressing files and data
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=compression&lang=en>
Yes, and Windows includes the functionality intrinsically as a shell
extension, so I thought it natural it would be part of the FCL. Based
on the two responses here, and all my googling, this is not the case.

Thanks for the replies. Already knew about and using SharpZipLib.
Jan 31 '08 #4
"Grok" <gr**@valhallalegends.comschrieb:
>>Trying to zip/unzip files from VB.NET 2005 with 2.0 .NET Framework ...
but the file created "SampleFile.zip" is not a readable zip file.

A ZIP file is more than a compressed stream.

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

Yes, and Windows includes the functionality intrinsically as a shell
extension, so I thought it natural it would be part of the FCL. Based
on the two responses here, and all my googling, this is not the case.
I specifically wanted to make you aware of these resources:

..NET 2.0 contains ZIP support in the namespace 'System.IO.Compression':

..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>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Jan 31 '08 #5

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

Similar topics

15
by: Simon Brooke | last post by:
I'm investigating a bug a customer has reported in our database abstraction layer, and it's making me very unhappy. Brief summary: I have a database abstraction layer which is intended to...
11
by: Grumble | last post by:
Hello, I have the following structure: struct foo { char *format; /* format string to be used with printf() */ int nparm; /* number of %d specifiers in the format string */ /* 0 <= nparm <=...
10
by: Asaf | last post by:
Hi, I am trying to Compress & Decompress a DataSet. When running this code I am receiving the error: System.Xml.XmlException was unhandled Message="Root element is missing."...
2
by: Brent Rogers | last post by:
I am having trouble with the DeflateStream.Read() method. For some reason it wants to return Zero. I have this set of classes: =================== using System; using...
2
by: Flpit | last post by:
Hi, Can anybody tell me how to use the System.IO.Compression Deflatestream Class. I have a byte which is a compressed set of bytes that form a block. I want to inflate the byte and return...
1
by: bthetford | last post by:
I am trying to roll a simple compression scheme for network communication in an app I am developing. On the sender side, I compress each block of a set amount of bytes individually, then send it...
4
by: =?Utf-8?B?Sm9uIEphY29icw==?= | last post by:
The compression part of this code works fine for me, but the decompression part of this code does not. The output file from that is the same as the compressed file. What is wrong with my code?...
1
by: sedwick | last post by:
I'm using .NET 2.0.50727 in VS 2005 Pro, ENU Service Pack 1 (KB926601). I've been experimenting with the System.IO.Compression classes GZipStream and DeflateStream, and I found it interesting to...
1
by: Smithers | last post by:
IIRC, we can use only System.IO.Compression.InflateStream to uncompress files compressed with System.IO Compression.DeflateStream. If that is in fact true, what are some alternatives you might...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.