【发布时间】:2010-11-20 00:25:02
【问题描述】:
Windows Phone 7 应用程序 该应用程序的目标是一个简单的待办事项列表。 我有一个类“todiitem”,我将这些对象添加到 Items 对象中。
在我看来,我正在做一些非常复杂的事情,而且很可能没有干净或体面的代码
但是我对“IsolatedStorageFile”有一些严重的问题
public class ToDoItem
{
public string ToDoName { get; set; } // Add controle's enz.
public string ToDoDescription { get; set; }
internal Priority PriortiySelection { get; set; }
...
}
Items 类(基本上是一个包装类,所以我可以访问它)
public class Items
{
public static List<ToDoItem> Itemslist = new List<ToDoItem>();
public static List<ToDoItem> GetList()
static methods here..
}
下面的代码返回以下异常:
"尝试访问该方法失败: System.Io.streamreader..ctor (System.String)"
然后我得到了
IsolatedStorageFileSTream 上不允许操作
if (store.FileExists(@"items.std"))
{
ToDoItem item = new ToDoItem();
try
{
IsolatedStorageFileStream save = new IsolatedStorageFileStream(@"items.std", FileMode.Open, store);
BinaryReader reader = new BinaryReader(save);
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
在公共部分类 NewToDo 中:PhoneApplicationPage 我添加了以下方法。它再次返回上述异常,我只假设它是由于某种原因允许的,或者我犯了一些巨大的错误。
private void saveItem(ToDoItem toDoItem)
{
try
{
using (StreamWriter sw = new StreamWriter(store.OpenFile(@"items.std", FileMode.Append)))
{
sw.WriteLine(toDoItem.ToDoName);
sw.WriteLine(toDoItem.ToDoDescription);
sw.WriteLine(toDoItem.PriortiySelection.ToString());
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
如果您需要更多信息,我很乐意提供,我目前是比利时一所大学二年级的学生,我正在玩 windows phone7 应用程序。
【问题讨论】:
标签: c# silverlight silverlight-4.0 windows-phone-7