C
Carl Johansson
How come the RemotingFormat property of the DataTable object has a
value of SerializationFormat.Xml? Please see the code below:
private static void WriteDataTableToBinary(DataTable dataTable)
{
dataTable.RemotingFormat = SerializationFormat.Binary; // Defaults
to "SerializationFormat.Xml".
dataTable.TableName = "SerializedTable";
BinaryFormatter binaryFormatter = new BinaryFormatter();
using (FileStream fileStream = new FileStream(@"C:\Data\Temp
\TableData.bin", FileMode.Create, FileAccess.Write))
binaryFormatter.Serialize(fileStream, dataTable);
}
private static DataTable ReadDataFromBinary()
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
using (FileStream fileStream = new FileStream(@"C:\Data\Temp
\TableData.bin", FileMode.Open, FileAccess.Read))
{
DataTable dataTable =
(DataTable)binaryFormatter.Deserialize(fileStream);
// Why "SerializationFormat.Xml", when it was
"SerializationFormat.Binary" when serialized???
Console.WriteLine(dataTable.RemotingFormat);
// In contrast, the TableName property has the expected value.
Console.WriteLine(dataTable.TableName);
return dataTable;
}
}
Regards Carl Johansson
value of SerializationFormat.Xml? Please see the code below:
private static void WriteDataTableToBinary(DataTable dataTable)
{
dataTable.RemotingFormat = SerializationFormat.Binary; // Defaults
to "SerializationFormat.Xml".
dataTable.TableName = "SerializedTable";
BinaryFormatter binaryFormatter = new BinaryFormatter();
using (FileStream fileStream = new FileStream(@"C:\Data\Temp
\TableData.bin", FileMode.Create, FileAccess.Write))
binaryFormatter.Serialize(fileStream, dataTable);
}
private static DataTable ReadDataFromBinary()
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
using (FileStream fileStream = new FileStream(@"C:\Data\Temp
\TableData.bin", FileMode.Open, FileAccess.Read))
{
DataTable dataTable =
(DataTable)binaryFormatter.Deserialize(fileStream);
// Why "SerializationFormat.Xml", when it was
"SerializationFormat.Binary" when serialized???
Console.WriteLine(dataTable.RemotingFormat);
// In contrast, the TableName property has the expected value.
Console.WriteLine(dataTable.TableName);
return dataTable;
}
}
Regards Carl Johansson