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(F n)
Dim dst As FileStream = File.Create(Ofn )
Dim cmp As New DeflateStream(d st, 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(O fn)
Dim slen As Integer = src.Length
Dim ba1(slen * 2) As Byte
cmp = New DeflateStream(s rc, CompressionMode .Decompress)
cmp.Read(ba1, 0, slen)
dst = File.Create(txt )
dst.Write(ba1, 0, slen)
cmp.Close()
src.Close()
dst.Close() 4 4176
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*******@disc ussions.microso ft.comwrote in message
news:9C******** *************** ***********@mic rosoft.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(F n)
Dim dst As FileStream = File.Create(Ofn )
Dim cmp As New DeflateStream(d st, 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(O fn)
Dim slen As Integer = src.Length
Dim ba1(slen * 2) As Byte
cmp = New DeflateStream(s rc, 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.Compr ession 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*******@disc ussions.microso ft.comwrote in message
news:3A******** *************** ***********@mic rosoft.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.Compr ession 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*******@disc ussions.microso ft.comwrote in message
news:3A******** *************** ***********@mic rosoft.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 impossible to
determine if a file, once added to an archive, will cause the archive
size to exceed the maximum size.
I believe that to do this properly,...
|
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 System.Collections.Generic;
using System.Text;
using System.IO;
using System.IO.Compression;
|
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 the new inflated byte.
|
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 over the NetworkStream along with the size
of the original data, the size of the compressed data, and a byte
telling the receiving end whether to...
|
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 note that they'll create different-sized compressed files depending on the procedure you use to take in the source file's data. With one, almost every...
| |
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 recommend?
I'm writing a Console app that, amongst other things compresses files. I
want to be able to uncompress the files using WinZip and other...
|
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 file)
How do I properly create a .zip file without 3rd-party lib?
Dim sourceFile As FileStream =
File.OpenRead("c:\temp\SampleFile.chm")
Dim...
|
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 get as large as about 150 KB.
(The client then generates an HTML page using the data in the XML file
and sends it to the browser. So there are 3...
|
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...
|
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...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| | |