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

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Feb 22 13:58:31 EST 2011


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

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


--- Comment #7 from Garth Tissington <gtissington at gmail.com> 2011-02-22 18:58:29 UTC ---
Perhaps I'm thick  but none of your suggestions have fixed my problem.

a) I update Mono to 2-10

b) I altered the code as you suggested.  (see below for the full listing)

c) If I run this code on an Osx Desktop it produces two 4kb files (of course I
alter it to be a console app not a Monotouch app)

d) when I run this on this iOs Simulator if get

-rw-r--r--  1 Garth  staff    0 22 Feb 10:51 test.dat
-rw-r--r--  1 Garth  staff  193 22 Feb 10:51 test.zip



--- code ---

using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;


using System.Xml;
using System.Xml.Serialization;
using System.IO;
using System.IO.Compression;

using System.Collections.Generic;
using System.Linq;


namespace TZipTest3
{
    public class Application
    {
        static void Main (string[] args)
        {
            UIApplication.Main (args);
        }
    }

    // The name AppDelegate is referenced in the MainWindow.xib file.
    public partial class AppDelegate : UIApplicationDelegate
    {
        // This method is invoked when the application has loaded its UI and
its ready to run
        public override bool FinishedLaunching (UIApplication app, NSDictionary
options)
        {
            // If you have defined a view, add it here:
            // window.AddSubview (navigationController.View);

            window.MakeKeyAndVisible ();


            TestRoot t;
            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 );


            XmlSerializer serDeflate = new XmlSerializer( typeof( TestRoot ));

            serDeflate.Serialize( gZipStream, t);

            XmlSerializer serGZip = new XmlSerializer( typeof( TestRoot ));
            serGZip.Serialize( deflateStream, t);

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

            gZipStream.Flush();
            deflateStream.Flush();


            gZipStream.Close();
            deflateStream.Close();

            fsZipFile.Close();
            fsDatFile.Close();

            return true;
        }

        // This method is required in iPhoneOS 3.0
        public override void OnActivated (UIApplication application)
        {
        }


    }

    [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.


More information about the mono-bugs mailing list