i have a simple Treeview for UWP (It is a external Control from Microsoft because UWP does not include a Treeview). I want to save Serialized the Tree to XML. I tried following Code
public static async void SaveTree(TreeView tree, string filename)
{
StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(@"C:\Users\IT\source\repos\App3\App3");
StorageFile file = await folder.GetFileAsync("test.xml");
using (IRandomAccessStream writeStream = await file.OpenAsync(FileAccessMode.ReadWrite))
{
Stream s = writeStream.AsStream();
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(s, tree.RootNode.Cast<TreeNode>().ToList());
}
}
But it gives always a unknown error. Maybe is this a wrong function for UWP?
Anyone know how to solve it ?
抱歉,在UWP中无法做到这一点。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.