The machine power was cut while, I assume, my application was updating a file. When turned back on and my application started it attempted to deserialize the file. The call to Serializer.Deserialize
did not fail, but the resulting object has default values for every property.
My file updating/saving:
using (FileStream theStream = File.Open(fileName + "_tmp", FileMode.Create)) {
ProtoBuf.Serializer.Serialize<MyObject>(theStream, inObjectToSerialize);
}
File.Copy(fileName + "_tmp", fileName, true);
There is no _tmp file, just the main file. The size of the file is non-zero which makes me believe the information is intact. Is there a way to recover this data?
Update:
I've tried the Marc's suggestion with ProtoReader and the file in questions causes an exception the be thrown at reader.ReadFieldHeader()
. The ProtoException reads: "Invalid field in source data:0"