[Mono-bugs] [Bug 668494] New: System.Io.Compression.DeflateStream not working

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Jan 31 19:47:19 EST 2011


https://bugzilla.novell.com/show_bug.cgi?id=668494

https://bugzilla.novell.com/show_bug.cgi?id=668494#c0


           Summary: System.Io.Compression.DeflateStream not working
    Classification: Mono
           Product: MonoTouch
           Version: unspecified
          Platform: x86
        OS/Version: Apple iOS 4.2
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Class Libraries
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: gtissington at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


I am using the DeflateStream object to compress a stream.  The stream is a
Serialized XML object.

When I use the GzipStream object it works perfectly.  When I switch to a
DeflateStream object the output file is zero bytes long. 

Unfortunately I need to use the Deflate format to support integration to a
legacy system.

Here is some sample code that produces the 0 byte file.  The .dat file will be
0 bytes while the .zip file is 4KB.

I have run this on the iOS simulator and the iPhone directly.  Same problem.

Thanks for your help.



            TestRoot t;
            XmlSerializer ser = new XmlSerializer( typeof( TestRoot ));
            string sZipFileName = Path.Combine( Environment.GetFolderPath
(Environment.SpecialFolder.Personal), "test.zip" );
            string sDatFileName = Path.Combine( Environment.GetFolderPath
(Environment.SpecialFolder.Personal), "test.dat" );
            if( File.Exists( sZipFileName ))
                File.Delete( sZipFileName );
            if( File.Exists( sDatFileName ))
                File.Delete( sDatFileName );

            t = new TestRoot ();

            FileStream fsZipFile = new FileStream( sZipFileName,
FileMode.Create );
            FileStream fsDatFile = new FileStream( sDatFileName,
FileMode.Create );

            GZipStream gZipStream = new GZipStream( fsZipFile,
CompressionMode.Compress );
            DeflateStream deflateStream = new DeflateStream( fsDatFile,
CompressionMode.Compress );


            ser.Serialize( gZipStream, t);
            ser.Serialize( deflateStream, t);

            fsZipFile.Flush();
            fsDatFile.Flush();

            fsZipFile.Flush();
            fsDatFile.Flush();





    [Serializable]
    public class TestRoot
    {
        public List<TestClass> Test { get; set; }

        public TestRoot()
        {
            Test = new List<TestClass>();
            Test.Add( new TestClass( "dfasd", "asdf", "safag" ));
            Test.Add( new TestClass( "dfasd", "asdf", "safag" ));
            Test.Add( new TestClass( "dfasd", "asdf", "safag" ));
            Test.Add( new TestClass( "dfasd", "asdf", "safag" ));
            Test.Add( new TestClass( "dfasd", "asdf", "safag" ));
            Test.Add( new TestClass( "dfasd", "asdf", "safag" ));
            Test.Add( new TestClass( "dfasd", "asdf", "safag" ));
            Test.Add( new TestClass( "dfasd", "asdf", "safag" ));
            Test.Add( new TestClass( "dfasd", "asdf", "safag" ));
            Test.Add( new TestClass( "dfasd", "asdf", "safag" ));
        }
    }

    [Serializable]
    public class TestClass
    {
        public string A { get; set; }
        public string B { get; set; }
        public string C { get; set; }

        public TestClass()
        {

        }
        public TestClass( string a, string b, string c)
        {
            A =a;
            B = b;
            C = c;
        }
    }

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list