DeflateStream.Read() returns zero

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brent Rogers

    DeflateStream.Read() 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...
  • Jon Skeet [C# MVP]

    #2
    Re: DeflateStream.R ead() returns zero

    Brent Rogers <BrentRogers@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 - <skeet@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

    Comment

    • Brent Rogers

      #3
      Re: DeflateStream.R ead() returns zero

      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 <BrentRogers@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 - <skeet@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
      >

      Comment

      Working...