I’ve been given a DataTable, and I’m trying to read it into Unity. I’ve been given some C# code to help out with it, but no good – it’s still erroring out, and I’m not quite sure how to fix it, or really where I should go to learn more. Suggestions welcome.
Code:
DataSet ds;
BinaryFormatter bf = new BinaryFormatter();
FileStream fs = new FileStream("Assets/SampleModelSerialized.dat", FileMode.Open);
try
{
ds = bf.Deserialize(fs) as DataSet;
}
catch (Exception err)
{
throw;
}
finally
{
fs.Close();
}
Error:
InvalidCastException: Cannot cast from source type to destination type.