【发布时间】:2012-03-28 09:12:36
【问题描述】:
我目前在我的 WPF 应用程序中有以下代码,它完全符合我的要求,但是,在发布此代码后,它不一定能够访问这些文件夹位置,因为它们不会指向正确的目录也不会存在文件夹。
我希望有人能告诉我将某些内容保存到本地文件夹的最佳方法是什么?
它是否在应用程序文件夹本身也没有问题。
我目前用于编写文件的代码:
using (Stream stream = File.Open(@"..\..\Templates\data.bin", FileMode.Create))
{
BinaryFormatter bin = new BinaryFormatter();
bin.Serialize(stream, templateList);
}
我目前用于加载文件的代码:
using (Stream stream = File.Open(@"..\..\Templates\data.bin", FileMode.Open))
{
BinaryFormatter bin = new BinaryFormatter();
templateList = (List<Template>)bin.Deserialize(stream);
}
【问题讨论】:
-
不确定我的问题是否正确,也许Isolated Storage 是您要找的?