A word Reading from txt file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • igzonefsd
    New Member
    • May 2007
    • 1

    A word Reading from txt file

    Hi,
    i am new to C#, i am developing an appilcation which will read from txt file. i have tried but i could not find how to read words instead of lines. if anyone knows the answer plz inform me.
  • Hybrid
    New Member
    • May 2007
    • 6

    #2
    string txt = System.IO.File. ReadAllText("c: \\text.txt");
    string[] lines = System.IO.File. ReadAllLines("c :\\text.txt");

    Hope that helps, if not; Please elaborate.

    Comment

    • vanc
      Recognized Expert New Member
      • Mar 2007
      • 211

      #3
      there is no way to read word by word in text file automatically, you have to read line by line and split those line by "space".

      string[] words = aLine.Split(" "); --> return all word in aLine

      cheers.

      Comment

      Working...