Return StreamReader to Beginning

后端 未结 7 1557
醉梦人生
醉梦人生 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:51

    This is all good if the BaseStream can actually be set Position property to 0.

    If you cannot (example would be a HttpWebResponse stream) then a good option would be to copy the stream to a MemoryStream...there you can set Position to 0 and restart the Stream as much as you want.

提交回复
热议问题