我創建了一個獨立存儲,它只存儲一個值並顯示一個值。 "aaaaaaaa,aaaaaaaa"
。
我怎樣才能讓這個它存儲
1)"aaaaaaaa,aaaaaaaaa"
2)"bbbbbbbb,bbbbbbbbb"
3)"cccccccccc,cccccccccc"
將多個值存儲到獨立存儲中
下面表明,只存儲一個值碼:
//get the storage for your app
IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication();
//define a StreamWriter
StreamWriter writeFile;
if (!store.DirectoryExists("SaveFolder"))
{
//Create a directory folder
store.CreateDirectory("SaveFolder");
//Create a new file and use a StreamWriter to the store a new file in
//the directory we just created
writeFile = new StreamWriter(new IsolatedStorageFileStream(
"SaveFolder\\SavedFile.txt",
FileMode.CreateNew,
store));
}
else
{
//Create a new file and use a StreamWriter to the store a new file in
//the directory we just created
writeFile = new StreamWriter(new IsolatedStorageFileStream(
"SaveFolder\\SavedFile.txt",
FileMode.Append,
store));
}
StringWriter str = new StringWriter();
str.Write(textBox1.Text);
str.Write(",");
str.Write(textBox2.Text);
writeFile.WriteLine(str.ToString());
writeFile.Close();
textBox1.Text = string.Empty;
textBox2.Text = string.Empty;
StringWriter str = new StringWriter();
str.Write(textBox1.Text);
str.Write(",");
str.Write(textBox2.Text);
writeFile.WriteLine(str.ToString());
writeFile.Close();
textBox1.Text = string.Empty;
textBox2.Text = string.Empty;
目前還不清楚你正在嘗試做什麼 - 創建一個多行文件或創建多個文件。 –
帶有多行的單個文件,謝謝修正。 – NoobieNeedHelp
對,多次調用'WriteLine',每行一次... –