我对以下代码有疑问。它应该防止覆盖文本文件中的记录。我的代码是这样的:
public static void WritingMethod()
{
StreamWriter Sw = new StreamWriter("fileone.txt", true);
string output = string.Format("Thank you for registration! Your Submitted information are:" + Environment.NewLine + "Name: {0}"
+ Environment.NewLine + "ID: {1}" + Environment.NewLine + "Age: {2}" + Environment.NewLine + "E-mail: {3}", Name, ID, Age, Email);
// I using the Environment.NewLine to insert new lines
Console.WriteLine(output);
Sw.WriteLine(output + Environment.NewLine);
Sw.Close();
}
它会覆盖记录。我想添加记录而不是覆盖它。