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() 4 4157
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()
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
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
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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: chris.atlee |
last post by:
I'm writing a program in python that creates tar files of a certain
maximum size (to fit onto CD/DVD). One of the problems I'm running
into is that when using compression, it's pretty much...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Stephany Young |
last post by:
Does anyone have the source code for a C# implementation of the AR2000
Compression/Decompression algorithm that they might like to share?
|
by: Grok |
last post by:
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...
|
by: Thomas Mlynarczyk |
last post by:
Hello,
I have a script that generates XML files which are sent to a client app
on request via "new SimpleXMLElement( $sUrl, 0, true )". Both client and
server run PHP 5.2 and the XML file can...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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,...
| | |