[英]StreamWriter and IsolatedStorageFile
IsolatedStorageFile iF = IsolatedStorageFile.GetUserStoreForApplication();
if (!iF.DirectoryExists("aaa"))
{
MessageBox.Show("No directory, create!");
iF.CreateDirectory("aaa");
}
StreamWriter fW = new StreamWriter(new IsolatedStorageFileStream("girls\\list.txt", FileMode.OpenOrCreate, iF));
fW.WriteLine(this.tb_name.Text);
因此,我創建或打開文件,並向其中添加文本框的內容。 我需要附加此文件,但會重寫。 請幫我解決這個問題:)謝謝!
您需要FileMode.Append
,而不是FileMode.OpenOrCreate
有關詳細信息,請參見本頁http://msdn.microsoft.com/zh-cn/library/system.io.filemode(v=vs.95).aspx
追加:打開文件(如果存在)並查找到文件末尾,或創建一個新文件。
使用FileMode.Append
因為如果它存在, FileMode.Create
如果它沒有。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.