所以我正在为我和我的朋友制作一个聊天程序。我在写消息时遇到问题,当我写消息时,整个文本文件都会被新消息替换。这是我的代码:
private void textBox1_TextChanged(object sender, EventArgs e)
{
String write = textBox1.Text;
try
{
StreamWriter sw = new StreamWriter(@"Path.txt");
sw.WriteLine(write);
sw.Close();
}
catch (Exception w)
{
Console.WriteLine("Exception: " + w.Message);
}
finally
{
}
}