By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,732 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

DeflateStream works for compression, but not decompression

P: n/a
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?
Thanks,
Jon
'compression starts here
Dim src As FileStream = File.OpenRead(Fn)
Dim dst As FileStream = File.Create(Ofn)
Dim cmp As New DeflateStream(dst, CompressionMode.Compress)

Dim ba(src.Length) As Byte
src.Read(ba, 0, src.Length)
cmp.Write(ba, 0, src.Length)
cmp.Close()
src.Close()
dst.Close()
'decompression starts here
src = File.OpenRead(Ofn)
Dim slen As Integer = src.Length
Dim ba1(slen * 2) As Byte

cmp = New DeflateStream(src, CompressionMode.Decompress)
cmp.Read(ba1, 0, slen)
dst = File.Create(txt)
dst.Write(ba1, 0, slen)

cmp.Close()
src.Close()
dst.Close()
Apr 26 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Did you find an answer to this? Are you still looking? I saw something
online about a problem with this, so if you're still looking, let me know
and I'll track down and post the url.

Robin S.
---------------------
"Jon Jacobs" <Jo*******@discussions.microsoft.comwrote in message
news:9C**********************************@microsof t.com...
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?
Thanks,
Jon
'compression starts here
Dim src As FileStream = File.OpenRead(Fn)
Dim dst As FileStream = File.Create(Ofn)
Dim cmp As New DeflateStream(dst, CompressionMode.Compress)

Dim ba(src.Length) As Byte
src.Read(ba, 0, src.Length)
cmp.Write(ba, 0, src.Length)
cmp.Close()
src.Close()
dst.Close()
'decompression starts here
src = File.OpenRead(Ofn)
Dim slen As Integer = src.Length
Dim ba1(slen * 2) As Byte

cmp = New DeflateStream(src, CompressionMode.Decompress)
cmp.Read(ba1, 0, slen)
dst = File.Create(txt)
dst.Write(ba1, 0, slen)

cmp.Close()
src.Close()
dst.Close()

May 9 '07 #2

P: n/a
Did you find an answer to this? Are you still looking? I saw something
online about a problem with this, so if you're still looking, let me know
and I'll track down and post the url.
Thank you. No, I never found out why this code did not work. I would
appreciate that url.

Jon
May 9 '07 #3

P: n/a
Here's the info I have tucked away about doing compression in .Net.
According to this article, you can do compression with the .Net
System.IO.Compression class, although there are some anomalies with the
DeflateStream class (see the bottom of the page, in red).

http://blogs.msdn.com/dotnetinterop/...zip-files.aspx

Another article:

http://www.windowsdevcenter.com/pub/...in-net-20.html

Here is an OpenSource project available here:
http://www.icsharpcode.net/OpenSource/SharpZipLib/

Hope this helps.
Robin S.
-----------------------------------
"Jon Jacobs" <Jo*******@discussions.microsoft.comwrote in message
news:3A**********************************@microsof t.com...
>Did you find an answer to this? Are you still looking? I saw something
online about a problem with this, so if you're still looking, let me
know
and I'll track down and post the url.
Thank you. No, I never found out why this code did not work. I would
appreciate that url.

Jon

May 20 '07 #4

P: n/a
Thank you very much for your interest and help.
Jon

"RobinS" wrote:
Here's the info I have tucked away about doing compression in .Net.
According to this article, you can do compression with the .Net
System.IO.Compression class, although there are some anomalies with the
DeflateStream class (see the bottom of the page, in red).

http://blogs.msdn.com/dotnetinterop/...zip-files.aspx

Another article:

http://www.windowsdevcenter.com/pub/...in-net-20.html

Here is an OpenSource project available here:
http://www.icsharpcode.net/OpenSource/SharpZipLib/

Hope this helps.
Robin S.
-----------------------------------
"Jon Jacobs" <Jo*******@discussions.microsoft.comwrote in message
news:3A**********************************@microsof t.com...
Did you find an answer to this? Are you still looking? I saw something
online about a problem with this, so if you're still looking, let me
know
and I'll track down and post the url.
Thank you. No, I never found out why this code did not work. I would
appreciate that url.

Jon


May 21 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.