Welcome to the Xceed Community | Help
Community Search  
More Search Options

This CompressedStream object does not support reading or decompressing.

Sort Posts: Previous Next
  •  05-26-2012, 6:19 PM Post no. 32153

    This CompressedStream object does not support reading or decompressing.

    Hmmm. Just purchased, so maybe I am missing something. I copied this code out of the StreamDemo project into a VS2010 console app:

    FileStream sourceStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
    FileStream destStream = new FileStream(fileName + ".zip", FileMode.Create, FileAccess.Write);
    CompressedStream compStream = new CompressedStream(destStream, CompressionMethod.PPMd, CompressionLevel.Normal);
    StreamCopy(compStream, destStream);

    private static void StreamCopy(Stream sourceStream, Stream destStream)
            {
                try
                {
                    int bytesRead;
                    byte[] buffer = new byte[32768];

                    while ((bytesRead = sourceStream.Read(buffer, 0, buffer.Length)) > 0)
                        destStream.Write(buffer, 0, bytesRead);
                }
                finally
                {
                    sourceStream.Close();
                    destStream.Close();
                }
            }

    fileName is a valid XML file. I verified that the file stream is loading the file properly, and there is a zero-byte file being created for destination. However, this line: while ((bytesRead = sourceStream.Read(buffer, 0, buffer.Length)) > 0) raises this error: This CompressedStream object does not support reading or decompressing.

    What am I missing?

  •  05-28-2012, 2:45 PM Post no. 32158 in reply to 32153

    Re: This CompressedStream object does not support reading or decompressing.

    Hi Michael,

    I think you did a mistake when copying the code from the StreamDemo project.

    The DoCompress() and DoDecompress() methods in the project are slightly different. The creation of the sourceStream and destStream are the same, but the compStream and the call to StreamCopy are different. You seem to have use the StreamCopy call from DoDecompress() but with the compStream code from DoCompress().

     


    ** Quick Tip: Clients with an active support subscription should be sending their questions by email if they wish to benefit from the faster response time. Thanks!


    Diane Lafontaine
    Technical Support
    Xceed Software Inc.
  •  05-29-2012, 8:57 PM Post no. 32180 in reply to 32158

    Re: This CompressedStream object does not support reading or decompressing.

    Thanks for your help! I did copy it wrong. Smile

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.