用streamreaderTXT读怎么让他显示成一行行的,,,为什么读出来的是不会换行的?
protectedvoidButton1_Click(objectsender,EventArgse){FileStreamfs=newFileStream("C:\\j...
protected void Button1_Click(object sender, EventArgs e)
{
FileStream fs = new FileStream("C:\\jijian.txt", FileMode.Open, FileAccess.Read);
StreamReader m_streamReader = new StreamReader(fs, System.Text.Encoding.GetEncoding("GB2312")); //使用StreamReader类来读取文件
m_streamReader.BaseStream.Seek(0, SeekOrigin.Begin); // 从数据流中读取每一行,直到文件的最后一行,并在TextBox1中显示出内容
this.TextBox1.Text = "";
string strLine = m_streamReader.ReadLine();
{
string line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = m_streamReader.ReadLine()) != null)
{
Console.WriteLine(line);
this.TextBox1.Text += strLine + "\n";
strLine = m_streamReader.ReadLine();
}
} 展开
{
FileStream fs = new FileStream("C:\\jijian.txt", FileMode.Open, FileAccess.Read);
StreamReader m_streamReader = new StreamReader(fs, System.Text.Encoding.GetEncoding("GB2312")); //使用StreamReader类来读取文件
m_streamReader.BaseStream.Seek(0, SeekOrigin.Begin); // 从数据流中读取每一行,直到文件的最后一行,并在TextBox1中显示出内容
this.TextBox1.Text = "";
string strLine = m_streamReader.ReadLine();
{
string line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = m_streamReader.ReadLine()) != null)
{
Console.WriteLine(line);
this.TextBox1.Text += strLine + "\n";
strLine = m_streamReader.ReadLine();
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询