Moving the file cursor up lines?

后端 未结 3 532
囚心锁ツ
囚心锁ツ 2021-01-21 01:01

I\'ve googled this like crazy, and I can\'t seem to find any reference at all to this particular type of problem.

I have a StreamReader object with a file,

3条回答
  •  旧巷少年郎
    2021-01-21 01:27

    there is no way to position to an exact line... only to absolute or relative byte within the file... if you need to position to a line you will need to implement that yourself - either by loading the file into a string[] (not recommended for big files!) or by scanning the file and building an index containing the absolute position for each line so you can later on use that index to Seek to the needed line...

提交回复
热议问题