1
我想从列表框中打印内容到文本文件,但它似乎不工作。 SortedFlats文本文件不显示任何内容。c#将列表框内容写入文本文件
protected void printImageButton_Click(object sender, ImageClickEventArgs e)
{
StreamWriter flatStreamWriter = new StreamWriter(Server.MapPath("~") + "SortedFlats.txt");
for (int i = 0; i < flatListBox.Items.Count; i++)
{
flatStreamWriter.WriteLine(flatListBox.Items[i].ToString());
}
flatStreamWriter.Close();
}
'Server.MapPath'?的WinForms? –
对不起,这不是winforms。它是Web应用程序。 – user2699500