473,387 Members | 1,528 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,387 software developers and data experts.

DeflateStream.Read() returns zero

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;

namespace SSNCDataLoad
{
interface IDataLoadParse
{
void Parse( Stream inStream
,Stream outStream);
}

public class StdParse : IDataLoadParse
{
virtual public void Parse( Stream inStream
,Stream outStream)
{
const int len = 1024;

Byte[] ba = new Byte[len];

for( int i = inStream.Read( ba, 0, len);
i != 0;
i = inStream.Read( ba, 0, len) )
{
outStream.Write( ba, 0, i );
}
}
}

public class InflateParse : StdParse, IDataLoadParse
{
override public void Parse( Stream inStream
,Stream outStream)
{
FileStream fs = new FileStream(@"c:\Starbuck_log.txt", FileMode.Open,
FileAccess.Read, FileShare.Read);
MemoryStream ms = new MemoryStream();
DeflateParse dfs = new DeflateParse();

dfs.Parse( fs, ms );
fs.Close();

ms.Position = 0;
// base.Parse(inStream, Str);
// Str.Seek(0, SeekOrigin.Begin);

DeflateStream dStream = new DeflateStream(ms, CompressionMode.Decompress);

base.Parse( dStream, outStream);
}
}

public class DeflateParse : StdParse, IDataLoadParse
{
override public void Parse(Stream inStream
, Stream outStream)
{
DeflateStream dStream = new DeflateStream(outStream,
CompressionMode.Compress );

base.Parse(inStream, dStream);
}
}

public class BarParse : StdParse, IDataLoadParse
{
public override void Parse(Stream inStream, Stream outStream)
{
FileStream fs1 = new FileStream(@"C:\InFile.xxx", FileMode.Open );
DeflateStream Str = new DeflateStream(fs1, CompressionMode.Decompress);
FileStream Stw = new FileStream(@"C:\InFile.xxx.txt", FileMode.Create);

base.Parse(Str, Stw);

Stw.Close();
Str.Close();
fs1.Close();

}
}
}
===================

My main program connects to an FTP site and trys to download a file. We
then create the appropriate object above and call the Parse() method. The
FtpResponseStream from the FTP connection is passed in as the inputStream. A
FileStream or MemoryStream object is used as the output stream. However for
some reason the Read() method returns zero.

Any Ideas...
Oct 4 '06 #1
2 4476
Brent Rogers <Br*********@discussions.microsoft.comwrote:
I am having trouble with the DeflateStream.Read() method. For some reason
it wants to return Zero.
Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

The set of classes you've given seems to be more than is required, but
you haven't given the use of the class. A complete example would be
very helpful. You may want to provide sample data to be copied to a
local drive in the form of a link to a website.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 4 '06 #2
Jon

In preparing my paired down test app, things started working. Don't know
what I did -- very strange

Thank You any way.

"Jon Skeet [C# MVP]" wrote:
Brent Rogers <Br*********@discussions.microsoft.comwrote:
I am having trouble with the DeflateStream.Read() method. For some reason
it wants to return Zero.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

The set of classes you've given seems to be more than is required, but
you haven't given the use of the class. A complete example would be
very helpful. You may want to provide sample data to be copied to a
local drive in the form of a link to a website.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 5 '06 #3

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

Similar topics

4
by: Meenakshi Matai | last post by:
I am trying to read data from a .dat file using fread. This is how my syntax looks: temp = fread(indata, sizeof(short int), 1, datafile); I looked into the data file in Hex format and saw that...
10
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp "If the value of the variant argument is Null, the Nz function returns the number zero or a...
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."...
3
by: Carlo Stonebanks | last post by:
I need to read a binary file which has mixed data types embedded in it. Fixed length strings, 16-bit integers and zero (null) terminated ASCII strings. (akak ASCIIZ) The first two types are no...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
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,...
0
jinu1996
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 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.