简体   繁体   中英

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);

So, I create file, or open it, and add to it content of textbox. I need append this file, but it rewrites. Please, help me to solve this problem :) Thank you!

You want FileMode.Append , not FileMode.OpenOrCreate

See this page for details http://msdn.microsoft.com/en-us/library/system.io.filemode(v=vs.95).aspx

Append: Opens the file if it exists and seeks to the end of the file, or creates a new file.

使用FileMode.Append因为如果它存在, FileMode.Create如果它没有。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM