怎么用StreamReader把一个文本文件中的所有行都读出来? 用ReadLine,加个循环,不就读出来了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 StreamReader sr = new StreamReader(""); while(sr.ReadLine()!=null) { }StreamReader是个指针,会一直向下走 while (sr.peek() != -1){} StreamReader reader= new StreamReader(strm); string tmpstr; reader.BaseStream.Seek(0, SeekOrigin.Begin); while (reader.Peek() > -1) { tmpstr = reader.ReadLine(); } string FileName = Application.StartupPath + "\\favorite.txt"; StreamReader sr = new StreamReader(FileName, System.Text.Encoding.UTF8); string strLine; while (sr.ReadLine() != null) { strLine = sr.ReadLine(); this.listBox1.Items.Add(strLine); } sr.Close();未处理的“System.ArgumentNullException”类型的异常出现在 system.windows.forms.dll 中其他信息:值不能为空。 string strLine;while ((strLine=sr.ReadLine()) != null){ this.listBox1.Items.Add(strLine);} 求一个类似google输入提示的控件! 初学asp.net。 C#如何实现类似sqlserver2000的导航树和右边数据列表的动态切换的功能 字符取值問題 为什么C#里bool要用4bytes来存储,java中不是1bit就搞定了么?? textBox的输入限制问题 C#中如何传一个空的datetime进存储过程 如何在dataGrid中加一个LinkLabel控件? C# Winform Timer倒计时问题 只能用一次 非常着急!!关于空间访问,在线等待!!!! 请问window2000自带的smtp怎么使用? 大家好,我是新手,想学C#,请大家推荐几本好书给我入门吧,谢谢!
while(sr.ReadLine()!=null)
{
}
StreamReader是个指针,会一直向下走
{}
string tmpstr;
reader.BaseStream.Seek(0, SeekOrigin.Begin);
while (reader.Peek() > -1)
{
tmpstr = reader.ReadLine();
}
StreamReader sr = new StreamReader(FileName, System.Text.Encoding.UTF8);
string strLine;
while (sr.ReadLine() != null)
{
strLine = sr.ReadLine();
this.listBox1.Items.Add(strLine);
}
sr.Close();
未处理的“System.ArgumentNullException”类型的异常出现在 system.windows.forms.dll 中其他信息:值不能为空。
while ((strLine=sr.ReadLine()) != null)
{
this.listBox1.Items.Add(strLine);
}