473,756 Members | 2,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DeflateStream.R ead() returns zero

I am having trouble with the DeflateStream.R ead() method. For some reason
it wants to return Zero.

I have this set of classes:
=============== ====
using System;
using System.Collecti ons.Generic;
using System.Text;
using System.IO;
using System.IO.Compr ession;

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.t xt", 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(inSt ream, Str);
// Str.Seek(0, SeekOrigin.Begi n);

DeflateStream dStream = new DeflateStream(m s, CompressionMode .Decompress);

base.Parse( dStream, outStream);
}
}

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

base.Parse(inSt ream, 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(f s1, 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
FtpResponseStre am 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 4502
Brent Rogers <Br*********@di scussions.micro soft.comwrote:
I am having trouble with the DeflateStream.R ead() 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.co m>
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*********@di scussions.micro soft.comwrote:
I am having trouble with the DeflateStream.R ead() 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.co m>
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
6545
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 everytime fread finds the data "1A" it returns a non-zero value. I tried with another .dat file and the same thing happens. I went in and manually changed the contents of the .dat file.
10
4588
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 zero-length string (always returns a zero-length string when used in a query expression)" **** How many records are there in FirstTable in which Product Is Null. SELECT COUNT(*) AS CountofNullProdcut
10
17845
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." Source="System.Xml" The code:
3
5630
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 problem, but the zero terminated string is a problem because I have to read byte--by-byte with BinaryStream(), and I don't know whether the class or the O/S uses buffering to make this efficient. Is my code slowing the app down - is there a better...
2
3583
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.
1
2335
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 expect more. On the receiving end, these blocks are received along with that size data and buffers...
4
4189
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? 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)
1
10208
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 file I feed them for compression ends up significantly bigger. That code is below, almost verbatim...
1
2615
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 similar and generally available compression/uncompression utilities. I have seen and used 7-Zip,...
0
9456
marktang
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10040
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, 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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2666
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.