怎么生成TXT文档
FileStream fsInfo = new FileStream("d:/试题.txt", FileMode.OpenOrCreate, FileAccess.Write);StreamWriter swInfo = new StreamWriter(fsInfo, Encoding.UTF8);
swInfo.Flush();
swInfo.BaseStream.Seek(0, SeekOrigin.Begin);
foreach (DataGridViewRow row in this.dataGridView1.Rows)
{
string str = String.Empty;
foreach (DataGridViewCell col in row.Cells)
{
str += col.Value + " ";
}
str += swInfo.NewLine;
swInfo.Write(str);
以上代码是将dataGridView1中的全部内容写入TXT文档,我在dataGridView1中已经加入可供选择的按钮,请问如何把自己的选择内容写入TXT文档中,谢谢!!!