Windows Phone 7應用程序 應用程序的目標是一個簡單的待辦事項列表。 我有一個類'toditem'我將這些對象添加到Items對象。silverlight,保存加載,IsolatedStorageFile和IsolatedStorageFileStream。異常
在我看來,我做的事情非常複雜,最有可能不乾淨或像樣的代碼
但我有一些嚴重的問題,「IsolatedStorageFile」
public class ToDoItem
{
public string ToDoName { get; set; } // Add controle's enz.
public string ToDoDescription { get; set; }
internal Priority PriortiySelection { get; set; }
...
}
項目類(basicly包裝CLAS所以我可以存取權限的話)
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應用玩耍。
由於有隊友,現在我能夠存儲和保存我的對象艱難吧沒有「serializedCollectionObject」這也不行?在silverlight? 接下來是詳細信息。 – Syneryx 2010-11-20 17:00:43