Return StreamReader to Beginning

后端 未结 7 1509
醉梦人生
醉梦人生 2020-11-27 05:18

I\'m reading a file in line-by-line and I want to be able to restart the read by calling a method Rewind().

How can I manipulate my System.IO.Stre

相关标签:
7条回答
  • 2020-11-27 05:56

    I use this method:

    System.IO.StreamReader reader = new System.IO.StreamReader("file.txt")
    //end of reading
    reader.DiscardBufferedData();
    reader.BaseStream.Seek(0, System.IO.SeekOrigin.Begin); 
    
    0 讨论(0)
提交回复
热议问题