0

I am reading a file using FileStream. Sometimes my stream position is in a middle of a sentence and I need to move it to the end of the sentence (all sentences are separated by line break). What I am planning to do is finding the offset of the carriage return (\r) and then set the position to it using FileStream.Seek.

Example:

HELLO, HALLO HOLLA.

YES YES YES

My cursor is right after 'HALLO' and I want the offset of carriage return in front of the next sentence (YES YES YES)

Is there any function to get the offset of the next carriage return? I am a student and still learning. Appreciate all your feedback and comments :)

blenzcoffee
  • 851
  • 1
  • 11
  • 35

1 Answers1

0

You're not thinking "in streams" - in an "ideologically pure" Stream you cannot reposition the stream pointer (aka "seeking", changing the "Position" property), you must keep track of all previous data yourself, usually with sort of state machine or other data structure.

I have a question: why do you want to find the byte position of \r? What is the "big thing" you want to accomplish? I suspect there is an easier way.

Dai
  • 141,631
  • 28
  • 261
  • 374