如何在不使用Streamwriter的情况下将数据写入文本文档 [英] How Can I Write Data Into A Text Document Without Using Streamwriter
本文介绍了如何在不使用Streamwriter的情况下将数据写入文本文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以帮助我如何在不使用C#窗体形式的streamwriter的情况下将数据写入文本文档。
谢谢。
解决方案
您可以使用这些方法在不使用streamwriter的情况下在文本文件中写入文本。
File.WriteAllText( @ d:\test.txt, 你好,你好吗?\ rr \ n Hello Word);
File.WriteAllLines( @ d:\test.txt, Hello Word);
尝试在datagridview中加载记录后的以下代码。
string str = ;
for ( int i = 0 ; i< dataGridView1.RowCount; i ++)
{
for ( int j = 0 ; j < dataGridView1.ColumnCount; j ++)
{
str + = dataGridView1.Rows [i] .Cells [j] .Value.ToString()+ ;< /跨度>;
}
str + = Environment.NewLine;
}
System.IO.File.AppendAllText( @ d:\ anand.txt ,str);
谢谢,
Anand。 G
您好Karthik Achari,
我已经在您的上下文中提到了一篇关于您的要求的文章。代码存在于以下链接中。
FlatFile数据库系统 [ ^ ]
检查代码。
谢谢&问候,
Anand。 ģ
Can anyone help me how to write data into a text document without using streamwriter in C# windows form.
Thanks.
解决方案
You can use these methods for writing the text in text file without using streamwriter.
File.WriteAllText(@"d:\test.txt","Hi how are you? \r\n Hello Word"); File.WriteAllLines(@"d:\test.txt","Hello Word");
Try the the following code after loading the records in datagridview.
string str=""; for(int i=0;i<dataGridView1.RowCount;i++) { for (int j = 0; j < dataGridView1.ColumnCount; j++) { str += dataGridView1.Rows[i].Cells[j].Value.ToString() +";"; } str += Environment.NewLine; } System.IO.File.AppendAllText(@"d:\anand.txt", str);
Thanks,
Anand. G
Hi Karthik Achari,
I have posted a article regarding to your requirement as you mentioned in context. The code is present in the following link.
FlatFile Database System[^]
Check the code.
Thanks & Regards,
Anand. G
这篇关于如何在不使用Streamwriter的情况下将数据写入文本文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文