moving file pointer at the begining

Hi,

I am searching for some text in a text file. Seach strings are stored in an array. Once I find first text string, I want to move the file pointer back to the file beginning. I know in C there used to be some way to do it. How to do the same in the C#

Thanks in advance,



Answer this question

moving file pointer at the begining

  • 硕鼠

    Wouldn't it be faster to just read the entire file into a string array and search that Or even a type of lazy initialisation that reads the string array to date then keeps reading the file for each string you're searching for

    I don't see any way to move the file pointer, beyond closing and reopening the file.



  • Bi#

    Set the Position property of the FileStream you're reading from to zero (or use the Seek method). If you have a StreamReader wrapped around the stream for reading the text, make sure you call its DiscardBufferedData method.



  • moving file pointer at the begining