我想從一個文本框到internalStorage保存文本,並從那裏加載它...Phone7的,另一個IsolatedStorageFile問題
節省部分工作正常。但加載不起作用我已經嘗試了很多教程。
private void button2_Click(object sender, RoutedEventArgs e)
{
//get selected FileName from listBox
string selItem = listBox1.SelectedItem.ToString();
IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();
if (selItem != null)
{
IsolatedStorageFileStream fileStream = store.OpenFile(selItem, FileMode.Open, FileAccess.Read);
using (StreamReader sr = new StreamReader(fileStream))
{
String line = "";
//Debug.WriteLine("ReadLine");
if ((line = sr.ReadLine()) != null)
{
//Debug.WriteLine("ReadLineText");
textBox1.Text = line;
}
sr.Close();
}
fileStream.Close();
}
}
相反的:
if ((line = sr.ReadLine()) != null)
{
//Debug.WriteLine("ReadLineText");
textBox1.Text = line;
我已經嘗試了許多可能性,例如:textBox1.Text = sr.ReadLine();等..
約他代碼奇怪的是:如果我例如輸入:
IsolatedStorageFileStream fileStream = store.OpenFile("text0.txt", FileMode.Open, FileAccess.Read);
它工作正常的單個文件text0.txt。
如果有人給我一些技巧來修復代碼,那真的太棒了。
在此先感謝..
你是從模擬器加載文件?因爲孤立的文件存儲從一個空白的石板開始 –
耶,我知道但是謝謝。我首先創建了一些測試文件... – infinitesimalLeanne
例外情況是:IsolatedStorageFileStream不允許操作。 – infinitesimalLeanne