i am serializing a treeview with its nodes , into xml file.
And when i deserialize back from the xml file.
I can't find the whole content of my treeview in the XML.
The problem, that in this treeview I have added a tag with specific type that i got from a cognex sdk. I guess this type is not serializable?
I can't find the tag , i putted before serializing it , here is how I serialize the object:
public static void SaveTree(TreeView tree, string filename)
{
using (Stream file = File.Open(filename, FileMode.Create))
{
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(file, tree.Nodes.Cast<TreeNode>().ToList());
}
}
public static TreeView LoadTree(string filename)
{
TreeView tree=new TreeView();
using (Stream file = File.Open(filename, FileMode.Open))
{
BinaryFormatter bf = new BinaryFormatter();
object obj = bf.Deserialize(file);
TreeNode[] nodeList = (obj as IEnumerable<TreeNode>).ToArray();
tree.Nodes.AddRange(nodeList);
}
return tree;
}
I guess the type is not serialisable , so what should i do ? How can I serialize this object?