这是我的代码:
protected void btnShow_Click(object sender, EventArgs e)
{
System.IO.StreamWriter stringWriter = new System.IO.StreamWriter(Server.MapPath(@"~/Puzzle/puzzle.txt"));
foreach (Control control in Panel1.Controls)
{
var textBox = control as TextBox;
if (textBox != null)
{
if (string.IsNullOrEmpty(textBox.Text))
{
textBox.Style["visibility"] = "hidden";
}
stringWriter.Write(textBox.Text+",");
} // end of if loop
}
stringWriter.Close();
}// end of button
例如,我的文本文件如下所示:
,S,U,P,,,,,,,,
我希望它在我的文本文件中是这样的:
,S,U,P,
,,,,
,,,,
我希望它在击中第 4 个逗号后进入下一行。
我该怎么做?