簡體   English   中英

StreamWriter和IsolatedStorageFile

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM