Reading any document chracter by character

来源:百度文库 编辑:神马文学网 时间:2024/10/01 10:47:19

well you can read character by character doing it this way, reading it line by line then go through each character:

 

using (StreamReader theReader = new StreamReader("filename.txt"))

{

   while (theReader.EndOfStream == false)

   {

      string currentLine = theReader.ReadLine();

      foreach(Char curChar in currentLine)

      {

         MessageBox.Show(curChar.ToString());

      }

   }

}

 

this will read each line and each character of that line.

for reading word documents, formatting of the document is different so you won't get much from it apart from maybe using the MS Word COM Interop approach (plenty examples here on the forms I believe) and reading the lines/paragraphs and going through each character, perhaps the same way as above.

Does this help?