我是WPF
and的初学者C#
。我正在尝试做电话簿作业。我不知道通过每次单击在文本文件中添加项目的语法。对不起,因为我的问题。
public MainWindow()
{
InitializeComponent();
System.IO.File.CreateText(@"E:\MYText.txt");
}
private void button1_Click(object sender, RoutedEventArgs e)
{
string Name01 = NameBox.Text;
string Name02 =FamilyNameBox.Text;
string Name03 = PhoneBox.Text;
string Informtion = Name01 + Name02 + Name03;
NameBox.Clear();
FamilyNameBox.Clear();
PhoneBox.Clear();
System.IO.StreamWriter MyWriter = new System.IO.StreamWriter(@"E:\MYText.txt", true);
MyWriter.Write(Informtion);
MyWriter.Close();
}