G
Guest
In .Net Framework 2.0 (VS2005) I'm having problems deserializing binary data
that was serialized and stored in a mysql 5.0 longblob field (stored via the
mysql data connector datareader object). I have modified the code to try
various suggestions I've seen in the forums, but no luck so far. Thanks in
advance for any light you can shed on this....
The error is "End of Stream encountered before parsing was completed."
The code used to serialize is:
Stream stream = new System.IO.FileStream("BinFile.bin",
FileMode.Create,
FileAccess.Write,
FileShare.None);
formatter.Serialize(stream,_DataValue.BinDataArray);
stream.Close();
//store binary data in approp db field.
this._ParentObject.CurrentData.Value_Binary =
GetBinaryData("BinFile.bin");
//the GetBinaryData function is:
private static byte[] GetBinaryData(string filePath)
{
System.IO.FileStream bstream = new FileStream(
filePath,FileMode.Open, FileAccess.Read);
BinaryReader reader = new BinaryReader(bstream);
byte[] BinaryOut = reader.ReadBytes((int)bstream.Length);
reader.Close();
bstream.Close();
return BinaryOut;
}
The code used to deserialize is:
FileStream stream;
BinaryWriter writer;
that was serialized and stored in a mysql 5.0 longblob field (stored via the
mysql data connector datareader object). I have modified the code to try
various suggestions I've seen in the forums, but no luck so far. Thanks in
advance for any light you can shed on this....
The error is "End of Stream encountered before parsing was completed."
The code used to serialize is:
Stream stream = new System.IO.FileStream("BinFile.bin",
FileMode.Create,
FileAccess.Write,
FileShare.None);
formatter.Serialize(stream,_DataValue.BinDataArray);
stream.Close();
//store binary data in approp db field.
this._ParentObject.CurrentData.Value_Binary =
GetBinaryData("BinFile.bin");
//the GetBinaryData function is:
private static byte[] GetBinaryData(string filePath)
{
System.IO.FileStream bstream = new FileStream(
filePath,FileMode.Open, FileAccess.Read);
BinaryReader reader = new BinaryReader(bstream);
byte[] BinaryOut = reader.ReadBytes((int)bstream.Length);
reader.Close();
bstream.Close();
return BinaryOut;
}
The code used to deserialize is:
FileStream stream;
BinaryWriter writer;