MohammadAmiry wrote:
I need to pass through the file and save the position of each keyword, so that when later, user wants me to read the keyword data from the file, I can seek to the position of the keyword and read the data.
OK. If you're using ReadLine to read the file, you won't get the LF character at the end of each line in the resulting string. ReadLine will strip the line termination characters for you. So, you simply have to add one to the character count of each line you read when you go to find each keyword. If you have a mix of file types, then you'll have to find out what the line termination characters are. Simply read the beginning of the file, character-by-character until you find either character 10 or 13, then check value of the next character to see if it is the opposite, 13 or 10, or if neither. This will tell you if the line termination is either CrLf, LfCr, or just Cr or Lf. You can adjust your character count accordingly.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007