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