我正在尝试编写一个代码,用户在文本框中输入交付详细信息并将文本添加到 txt 文件(记事本 txt 文件)中。这是我的尝试,我得到了额外的一行“,”,为什么它不将文本框中的文本添加到文本文件中?
private void FrmDelivery_Load(object sender, EventArgs e)
{
if (theDelivery != null)
{
txtCustomerName.Text = theDelivery.customerName;
txtCustomerAddress.Text = theDelivery.customerAddress;
txtArrivalTime.Text = theDelivery.arrivalTime;
using (StreamWriter writer = new StreamWriter("visits.txt", true)) //true shows that text would be appended to file
{
writer.WriteLine(theDelivery.customerName + ", " + theDelivery.customerAddress + ", " + theDelivery.arrivalTime);
}
}
}