user588935
user588935

Reputation: 1

How to read character by character from text file?

How to read character by character in line from text file?

Upvotes: 0

Views: 863

Answers (1)

CD..
CD..

Reputation: 74116

Use the StraemReader class. It has a Read() method that reads the next character from the input stream and advances the character position by one character. (Overrides TextReader.Read().)

For example:

using (StreamReader sr = new StreamReader(path)) 
{
     while (sr.Peek() >= 0) 
     {
         char c = (char)sr.Read();
     }
}

Upvotes: 1

Related Questions