Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
AnswerRe: String Formatting / Interpolation --- Opinions Pin
jschell22-Jan-16 14:01
jschell22-Jan-16 14:01 
GeneralRe: String Formatting / Interpolation --- Opinions Pin
Sascha Lefèvre22-Jan-16 23:06
professionalSascha Lefèvre22-Jan-16 23:06 
GeneralRe: String Formatting / Interpolation --- Opinions Pin
jschell28-Jan-16 12:48
jschell28-Jan-16 12:48 
GeneralI want to understand namespace System.Security Pin
BasmaSH19-Jan-16 20:01
BasmaSH19-Jan-16 20:01 
GeneralRe: I want to understand namespace System.Security Pin
dan!sh 19-Jan-16 20:53
professional dan!sh 19-Jan-16 20:53 
GeneralRe: I want to understand namespace System.Security PinPopular
CHill6020-Jan-16 0:38
mveCHill6020-Jan-16 0:38 
QuestionRemoving EXIF Does not work when using Different Encoders to Choose Format Pin
Member 1227351319-Jan-16 2:30
Member 1227351319-Jan-16 2:30 
QuestionProblem solved: problem de-serializing using GZip: file left "open" Pin
BillWoodruff17-Jan-16 1:45
professionalBillWoodruff17-Jan-16 1:45 
1. context: Windows Forms. last year I posted a question here GZip, and the code shown here is based on content in that thread: [^].

2. currently: I am successfully using GZip to serialize and de-serialize a very complex object.

3. the issue is: if I do two reads/de-serializations of the code I get the "being used by another process" file access error. so far research on the web has not solved the problem.

4. comparison with using WCF to serialize to 'xml: using this very standard code:
C#
using (FileStream fs = new FileStream(filepath, FileMode.Create))
{
    dcs.WriteObject(DataObject, this);
}
The serialized object can be de-serialized any number of times without the error seen using GZip.

5. the GZip code:

C#
using System.IO;
using System.IO.Compression;
using System.Runtime.Serialization;
// and other required libraries

public static DataObject DeSerialize(string filepath)
{
    DataContractSerializer dcs = new DataContractSerializer(typeof(DataObject));

    DataObject dto;

    using (MemoryStream xmlStream = new MemoryStream())
    {
        using(GZipStream deCompStream = new GZipStream(File.Open(filepath, FileMode.Open),CompressionMode.Decompress, true))
        {
            deCompStream.CopyTo(xmlStream);
            deCompStream.Close(); // using 'Close here fixes a common problem with WCF
            // must reset to beginning of stream
            xmlStream.Position = 0;
        }
        dto = (DataObject)dcs.ReadObject(xmlStream);
        xmlStream.Close();
    }

    return dto;
}
thanks, Bill
«Tell me and I forget. Teach me and I remember. Involve me and I learn.» Benjamin Franklin


modified 17-Jan-16 10:12am.

AnswerRe: problem de-serializing using GZip: file left "open" Pin
OriginalGriff17-Jan-16 2:32
mveOriginalGriff17-Jan-16 2:32 
SuggestionRe: problem de-serializing using GZip: file left "open" Pin
Sascha Lefèvre17-Jan-16 3:24
professionalSascha Lefèvre17-Jan-16 3:24 
GeneralRe: problem de-serializing using GZip: file left "open" Pin
BillWoodruff17-Jan-16 4:11
professionalBillWoodruff17-Jan-16 4:11 
GeneralRe: problem de-serializing using GZip: file left "open" Pin
Sascha Lefèvre17-Jan-16 5:41
professionalSascha Lefèvre17-Jan-16 5:41 
GeneralRe: problem de-serializing using GZip: file left "open" Pin
BillWoodruff17-Jan-16 4:06
professionalBillWoodruff17-Jan-16 4:06 
GeneralRe: problem de-serializing using GZip: file left "open" Pin
OriginalGriff17-Jan-16 4:21
mveOriginalGriff17-Jan-16 4:21 
GeneralRe: problem de-serializing using GZip: file left "open" Pin
BillWoodruff17-Jan-16 6:49
professionalBillWoodruff17-Jan-16 6:49 
QuestionHow to disable show again the same form ? Pin
Member 1224802814-Jan-16 0:16
Member 1224802814-Jan-16 0:16 
AnswerRe: How to disable show again the same form ? Pin
John Torjo14-Jan-16 4:02
professionalJohn Torjo14-Jan-16 4:02 
GeneralRe: How to disable show again the same form ? Pin
Member 1224802814-Jan-16 11:18
Member 1224802814-Jan-16 11:18 
GeneralRe: How to disable show again the same form ? Pin
Mycroft Holmes14-Jan-16 11:46
professionalMycroft Holmes14-Jan-16 11:46 
GeneralRe: How to disable show again the same form ? Pin
Member 1224802814-Jan-16 11:59
Member 1224802814-Jan-16 11:59 
GeneralRe: How to disable show again the same form ? Pin
Sascha Lefèvre14-Jan-16 12:14
professionalSascha Lefèvre14-Jan-16 12:14 
AnswerRe: How to disable show again the same form ? Pin
BillWoodruff14-Jan-16 21:30
professionalBillWoodruff14-Jan-16 21:30 
GeneralRe: How to disable show again the same form ? Pin
Member 1224802815-Jan-16 11:03
Member 1224802815-Jan-16 11:03 
Questionsending/receiving sms with c# code using smartphone Pin
Roberto64_Ge12-Jan-16 4:24
Roberto64_Ge12-Jan-16 4:24 
AnswerRe: sending/receiving sms with c# code using smartphone Pin
Dave Kreskowiak12-Jan-16 4:38
mveDave Kreskowiak12-Jan-16 4:38 

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.