Re: Serialization Question
From: Kyril Magnos (kyril.magnos_at_yahoo.com)
Date: 07/16/04
- Next message: adish11: "run application"
- Previous message: Scott Handojo: "Searching for subsets within multidimensional arrays"
- In reply to: Silesian: "Serialization Question"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 16 Jul 2004 13:41:19 -0700
Serialization does not support appending (at least not that I have read
anywhere, MSDN does not explicitly say this, but given how serialization
works, I can't imagine that it does work).
If you need to modify a serialized component, then you should deserialize it
first, then make your changes and then serialize it back, overwriting the
original file.
--
HTH
Kyril Magnos
Question of the day:
What is Mono?
A) Disease where the lymph nodes become swollen.
B) A single sound
C) A synonym for one
D) A port of .NET meant to royally irritate MSFT
E) All of the above.
"Silesian" <nospam@spamthis.com> wrote in message
news:10fgeh5ln8dgv04@corp.supernews.com...
|I realize that this is a newbie question but maybe someone will be able to
| tell me what am I doing wrong.
| createFile() gets called each time I have the user generate some numbers
| which then get added to the binlist ArrayList.
| I'm able to serialize and deserialize the Arraylist. However, when I
| deserialize the ArrayList, it will only show the first set of ints. I
| looked at the bin file and it does get appended to each time. Any help
will
| be appreciated.
| Rich
|
| private void createFile()
| {
| foreach (int a in num)
| {
| binlist.Add (a);
| }
|
| Stream streamAppend = File.Open("Numbers.bin",FileMode.Append);
| bf.Serialize (streamAppend,binlist);
| streamAppend.Close ();
| Stream streamRead = File.OpenRead("Numbers.bin");
| binlist=(ArrayList)bf.Deserialize (streamRead);
| streamRead.Close ();
| MessageBox.Show (binlist.Count .ToString ());
| for(int i = 0; i < binlist.Count ; i ++)
| {
| MessageBox.Show (binlist[i].ToString ());
| }
|
|
- Next message: adish11: "run application"
- Previous message: Scott Handojo: "Searching for subsets within multidimensional arrays"
- In reply to: Silesian: "Serialization Question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|