HI Here is my scenario where i have to serialize an object to a file.
I am using binaryformatter to serialize an object as,
IFormatter formatter = new BinaryFormatter();
formatter.Serialize(stream1, object);
I am writting GetObjectData() as follows,
serinfo.AddValue("string1",objecta);
serinfo.AddValue("string2",objectb);
serinfo.AddValue("string3",objectc);
I am serializing 2 lists list1, list2 in objectb. sizeof the lists vary time to time.(each list may also have 100000 elements.. means number of elements in list influence the size of the stream).so, when i serialize the object, my stream size should not exceed 10mb and If it exceeds i should write in another stream. simply to say, if size exceeds 10mb, i should have one more stream and each stream should be in following format
stream1 --> objecta,(objectb)some n values in list,objectc
stream2 --> objecta,(objectb)values in list from n+1 to some m,objectc
..
streamn --> ........
each stream size should be limited to 10mb..
Please provide me some clues to do this.. thanks in advance.. (first of all thanks for reading this large qn..:P)
I think I'd serialize my objects into a MemoryStream, then check if adding it into the current filestream would exceed 10MB, and start a new stream before writing if it would.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With