Click here to Skip to main content
15,885,366 members
Home / Discussions / C#
   

C#

 
GeneralRe: Grabbing a Tree displayed in a window Pin
Carsten Zeumer6-Jun-05 6:22
Carsten Zeumer6-Jun-05 6:22 
GeneralEnterprise Library exception block Pin
Member 10756526-Jun-05 4:34
Member 10756526-Jun-05 4:34 
GeneralMS Project 2003 development Pin
Okeno Palmer6-Jun-05 4:33
Okeno Palmer6-Jun-05 4:33 
Generalprint an array Pin
Anonymous6-Jun-05 4:30
Anonymous6-Jun-05 4:30 
GeneralRe: print an array Pin
User 66586-Jun-05 5:05
User 66586-Jun-05 5:05 
GeneralRe: print an array Pin
Anonymous6-Jun-05 6:40
Anonymous6-Jun-05 6:40 
Questionhow to save a structure inside a text file Pin
Anonymous6-Jun-05 4:22
Anonymous6-Jun-05 4:22 
AnswerRe: how to save a structure inside a text file Pin
S. Senthil Kumar6-Jun-05 5:40
S. Senthil Kumar6-Jun-05 5:40 
Use serialization. Look for the System.Runtime.Serialization namespace. There you'll find BinaryFormatter and SoapFormatter classes. Serializing and deserializing is very simple
// serialize
mystruct s = new mystruct();
using (FileStream f = new FileStream("Test.bin", FileMode.Create))
{
   new BinaryFormatter(f).Serialize(s);
}

// deserialize
using (FileStream f = new FileStream("Test.bin", FileMode.Open))
{
   mystruct m = (mystruct)new BinaryFormatter(f).Deserialize(s);
}


Just make sure that the struct and all its members have the [Serializable] attribute set.

Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
GeneralRe: how to save a structure inside a text file Pin
Anonymous6-Jun-05 6:39
Anonymous6-Jun-05 6:39 
GeneralRe: how to save a structure inside a text file Pin
nemopeti8-Jun-05 5:46
nemopeti8-Jun-05 5:46 
Questionhow to create a C# windows service which has a GUI. Pin
dilsudharaka6-Jun-05 2:46
dilsudharaka6-Jun-05 2:46 
AnswerRe: how to create a C# windows service which has a GUI. Pin
oykica6-Jun-05 6:31
oykica6-Jun-05 6:31 
Generalcombobox Pin
webhay6-Jun-05 2:16
webhay6-Jun-05 2:16 
GeneralRe: combobox Pin
MoustafaS6-Jun-05 2:36
MoustafaS6-Jun-05 2:36 
GeneralRe: combobox Pin
webhay6-Jun-05 2:44
webhay6-Jun-05 2:44 
GeneralRe: combobox Pin
MoustafaS6-Jun-05 3:29
MoustafaS6-Jun-05 3:29 
GeneralRe: combobox Pin
albCode6-Jun-05 4:33
albCode6-Jun-05 4:33 
GeneralRe: combobox Pin
webhay6-Jun-05 4:36
webhay6-Jun-05 4:36 
GeneralRe: combobox Pin
albCode6-Jun-05 4:41
albCode6-Jun-05 4:41 
GeneralRe: combobox Pin
webhay6-Jun-05 4:44
webhay6-Jun-05 4:44 
GeneralRe: combobox Pin
albCode6-Jun-05 6:38
albCode6-Jun-05 6:38 
GeneralData Overflow error Pin
UdayShetty6-Jun-05 2:05
UdayShetty6-Jun-05 2:05 
GeneralRe: Data Overflow error Pin
rocky_pulley6-Jun-05 2:24
rocky_pulley6-Jun-05 2:24 
GeneralRun time specification of arguments to method Pin
cmpipey6-Jun-05 2:01
cmpipey6-Jun-05 2:01 
GeneralRe: Run time specification of arguments to method Pin
Robert Rohde6-Jun-05 3:34
Robert Rohde6-Jun-05 3:34 

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.