Click here to Skip to main content
15,881,882 members
Home / Discussions / C#
   

C#

 
GeneralRe: Help Regarding OPEN XML, Pin
Dave Kreskowiak17-Jul-13 18:00
mveDave Kreskowiak17-Jul-13 18:00 
GeneralRe: Help Regarding OPEN XML, Pin
BillWoodruff17-Jul-13 18:11
professionalBillWoodruff17-Jul-13 18:11 
GeneralRe: Help Regarding OPEN XML, Pin
Dave Kreskowiak18-Jul-13 2:09
mveDave Kreskowiak18-Jul-13 2:09 
AnswerRe: Help Regarding OPEN XML, Pin
BillWoodruff17-Jul-13 17:28
professionalBillWoodruff17-Jul-13 17:28 
QuestionUsing Binary Serialization and GZip ? Pin
BillWoodruff17-Jul-13 3:14
professionalBillWoodruff17-Jul-13 3:14 
AnswerRe: Using Binary Serialization and GZip ? Pin
Richard Deeming17-Jul-13 4:02
mveRichard Deeming17-Jul-13 4:02 
GeneralRe: Using Binary Serialization and GZip ? Pin
BillWoodruff17-Jul-13 15:07
professionalBillWoodruff17-Jul-13 15:07 
AnswerRe: Using Binary Serialization and GZip ? Pin
Eddy Vluggen17-Jul-13 5:07
professionalEddy Vluggen17-Jul-13 5:07 
You're copying streams which isn't required; they're based on the decorator-pattern. Below example should work (albeit the GZipped version will be bigger since it's a small class)
C#
using System;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using System.IO.Compression;

[Serializable()]
class SumTestClass
{
    public int TestInt { get; set; }
    public string TestString { get; set; }
    public SumTestClass()
    {
        TestInt = 42;
        TestString = "Hello World";
    }
}

static class Program
{
    static BinaryFormatter bf = new BinaryFormatter();
    static void Main(string[] args)
    {
        object thingyToSerialize = new SumTestClass();

        // ..or use a memorystream :)
        using (var ms = new FileStream("C:\\Temp\\Test.zip", FileMode.Create)) 
        using (var zs = new GZipStream(ms, CompressionMode.Compress, leaveOpen: true))
        {
            bf.Serialize(zs, thingyToSerialize);
            Console.WriteLine("Stuff saved");
        }
        
        using (var ms = new FileStream("C:\\Temp\\Test.zip", FileMode.Open)) 
        using (var zs = new GZipStream(ms, CompressionMode.Decompress, leaveOpen: true))
        {
            SumTestClass testResult = bf.Deserialize(zs) as SumTestClass;
            Console.WriteLine("String: {0}\nInt: {1}", testResult.TestString, testResult.TestInt);
        }

        Console.ReadLine();
    }
}
Hope it helps a bit, yell if it doesn't Smile | :)
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]

GeneralRe: Using Binary Serialization and GZip ? Pin
BillWoodruff17-Jul-13 16:52
professionalBillWoodruff17-Jul-13 16:52 
GeneralRe: Using Binary Serialization and GZip ? Pin
Eddy Vluggen18-Jul-13 6:32
professionalEddy Vluggen18-Jul-13 6:32 
GeneralRe: Using Binary Serialization and GZip ? Pin
BillWoodruff18-Jul-13 17:00
professionalBillWoodruff18-Jul-13 17:00 
GeneralRe: Using Binary Serialization and GZip ? Pin
Eddy Vluggen19-Jul-13 7:30
professionalEddy Vluggen19-Jul-13 7:30 
GeneralRe: Using Binary Serialization and GZip ? Pin
harold aptroot18-Jul-13 7:17
harold aptroot18-Jul-13 7:17 
GeneralRe: Using Binary Serialization and GZip ? Pin
BillWoodruff18-Jul-13 17:04
professionalBillWoodruff18-Jul-13 17:04 
AnswerRe: Using Binary Serialization and GZip ? Pin
Ennis Ray Lynch, Jr.17-Jul-13 7:11
Ennis Ray Lynch, Jr.17-Jul-13 7:11 
GeneralRe: Using Binary Serialization and GZip ? Pin
BillWoodruff17-Jul-13 17:02
professionalBillWoodruff17-Jul-13 17:02 
QuestionWebBrowser and swf textbox and button Pin
Member 843530717-Jul-13 2:11
Member 843530717-Jul-13 2:11 
AnswerRe: WebBrowser and swf textbox and button Pin
Amir Mohammad Nasrollahi29-Jul-13 6:33
professionalAmir Mohammad Nasrollahi29-Jul-13 6:33 
Questionviewing and printing a pdf on different browser Pin
tasumisra17-Jul-13 0:25
tasumisra17-Jul-13 0:25 
AnswerRe: viewing and printing a pdf on different browser Pin
Bernhard Hiller17-Jul-13 21:43
Bernhard Hiller17-Jul-13 21:43 
GeneralRe: viewing and printing a pdf on different browser Pin
Amir Mohammad Nasrollahi29-Jul-13 6:40
professionalAmir Mohammad Nasrollahi29-Jul-13 6:40 
AnswerRe: viewing and printing a pdf on different browser Pin
Amir Mohammad Nasrollahi29-Jul-13 6:40
professionalAmir Mohammad Nasrollahi29-Jul-13 6:40 
QuestionProblem in creating Shortcut to desktop and uninstall program in user all program Pin
Sneha Bisht16-Jul-13 21:24
Sneha Bisht16-Jul-13 21:24 
AnswerRe: Problem in creating Shortcut to desktop and uninstall program in user all program Pin
Jay Nardev17-Jul-13 22:03
Jay Nardev17-Jul-13 22:03 
GeneralWindows Service: Timer vs Thread Pin
BBatts16-Jul-13 6:15
BBatts16-Jul-13 6:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.