I am trying to serialize/deserialize an object. The serialization works well, but the deserialization doesn't work. It seems that it is a unicode problem : There is a System.Text.DecoderFallbackException Exception that says that there is a Unicode problem (Translation French to English) :
Can not translate [FF] bytes to index 31 from the code page specified in Unicode.
I used the two functions for Binary serialization in deadlydog answer on the topic.
The question is, how can I specify a Unicode for deserialization and serialization in this code ?
EDIT :
Finaly I am using protobuf-net, here are my functions :
public static void WriteToBinaryFile<T>(string filePath, T objectToWrite, bool append = false)
{
using (var file = File.Open(filePath, append ? FileMode.Append : FileMode.Create))
{
Serializer.Serialize<T>(file, objectToWrite);
}
}
public static T ReadFromBinaryFile<T>(string filePath)
{
using (var file = File.Open(filePath, FileMode.Open))
{
return Serializer.Deserialize<T>(file);
}
}
But I have an error when I deserialize : Invalid field in source data: 0