C#读取txt文件的两种方法
2014-04-01 15:37
465 查看
//方法一
string[] strR = File.ReadAllLines("D:\\MyFile4.txt");//获取整个文本内容
//int iRow = strR.Length;//获取txt文件的行数
for (int iRow = 0; iRow < strR.Length; iRow++)
{
textBox1.Text += strR[iRow] + "\r\n";
}
//方法二
StreamReader sr1 = new StreamReader("D:\\MyFile4.txt");
while (sr1.Peek() >= 0)
{
string str1 = sr1.ReadLine();
textBox1.Text += str1+"\r\n";
}
string[] strR = File.ReadAllLines("D:\\MyFile4.txt");//获取整个文本内容
//int iRow = strR.Length;//获取txt文件的行数
for (int iRow = 0; iRow < strR.Length; iRow++)
{
textBox1.Text += strR[iRow] + "\r\n";
}
//方法二
StreamReader sr1 = new StreamReader("D:\\MyFile4.txt");
while (sr1.Peek() >= 0)
{
string str1 = sr1.ReadLine();
textBox1.Text += str1+"\r\n";
}
相关文章推荐
- C#读写txt文件的两种方法
- C#读写txt文件的两种方法介绍
- C#读写txt文件的两种方法介绍
- C#读写txt文件的两种方法介绍
- 用C#读取txt文件的方法(转)
- C#读写txt文件的两种方法介绍
- C#读写txt文件的两种方法介绍
- C#读写txt文件的两种方法介绍
- [转载]C#读写txt文件的两种方法介绍
- C#读写txt文件的两种方法介绍 Copy:http://blog.csdn.net/ybhjx/article/details/53706715
- C#读写txt文件的两种方法介绍
- C#读写txt文件的两种方法介绍
- C#读写txt文件的两种方法介绍
- C#读写txt文件的两种方法介绍
- 用C#读取txt文件的方法
- C#读写txt文件的两种方法介绍
- C#读写txt文件的两种方法介绍
- C#读写txt文件的两种方法介绍
- C#读写txt文件的两种方法介绍
- C#中Excel文件的读取的两种方法:Excel类和OleDb