0

I have tried to serialized a big class with a lot of strings by binary formatter using C#:

using (FileStream savedfile = new FileStream(FilePath, FileMode.Create, FileAccess.Write))
{
  BinaryFormatter bf = new BinaryFormatter();
  TheInfo info = new TheInfo();
  bf.Serialize(savedfile, info)
}

The speed of read and write is a little faster than the original XML S/L method.

However, when I opened the binary file by notepad, though most of them are unreadable, the value of the string is still as the original one and looks like not-be-serialized at all like:

$%^#$&%$#&this is a string.

My friend told me that this still can be improved. He said when the string being serialized, the entire binary file is totally unreadable and the loading speed can be further increased. Is that true? Is there still anyway I can do with this serialized file?

Flysword
  • 13
  • 4
  • Default `BinaryFormatter` produces binary data as you have seen - strings are not encoded, typenames also. – Konrad Kokosa Jan 21 '14 at 18:18
  • 1
    For fast serialization, check out this post: http://stackoverflow.com/questions/549128/fast-and-compact-object-serialization-in-net – Jon B Jan 21 '14 at 18:21

0 Answers0