用StreamReader.ReadLine()读取文件时不能读取第一个字符例如文本文件如下
aaa.txt
___________________
aaa,bbb,ccc
ddd,eee,fff
ggg,hhh,kkk________________用ReadLine()读取出来的结果是
aa,bbb,ccc
dd,eee,fff
gg,hhh,kkk请问这是怎么回事??程序代码如下FileStream fs = new FileStream("aaa.txt",System.IO.FileMode.Open,System.IO.FileAccess.Read,System.IO.FileShare.Read);
StreamReader str= new StreamReader(fs,System.Text.Encoding.Default);
string aa="";
while (str.Read()!=-1)
{
aa = str.ReadLine(); Console.WriteLine(aa); } Console.ReadLine();
aaa.txt
___________________
aaa,bbb,ccc
ddd,eee,fff
ggg,hhh,kkk________________用ReadLine()读取出来的结果是
aa,bbb,ccc
dd,eee,fff
gg,hhh,kkk请问这是怎么回事??程序代码如下FileStream fs = new FileStream("aaa.txt",System.IO.FileMode.Open,System.IO.FileAccess.Read,System.IO.FileShare.Read);
StreamReader str= new StreamReader(fs,System.Text.Encoding.Default);
string aa="";
while (str.Read()!=-1)
{
aa = str.ReadLine(); Console.WriteLine(aa); } Console.ReadLine();
{
aa = str.ReadLine(); //一次读一行。 看名称就知道了。 Console.WriteLine(aa); }
while(true)
{
aa=str.ReadLine();
if(aa==null) break;
Console.WriteLine(aa);
}
Console.ReadLine();