-3

I am trying to find a way for c# to parse a text(bat, txt) and to be able to grab information from the file by line. for example the file would be like this:

About
Menu
Staff
Contact 

basically i want to grab that information and use it else in the program but to keep this easy to edit for other people in the office without mucking about the actual code.

I'm pretty new to C#, I've done similar applications in C++, but i am not sure how i would port that over to c#. Thanks

  • System.IO.File.ReadAllLines() – 001 Jan 22 '14 at 19:57
  • 6
    Well what *specifically* are you trying to achieve, and what have you already tried? A search for "reading a text file in c#" gives plenty of hits, including ones on MSDN. It's a good idea to at least have a go at a problem before asking a question here. – Jon Skeet Jan 22 '14 at 19:57
  • thanks john, I have tried the one on MSDN, but i didn't get very far. – Protonblast Jan 22 '14 at 20:03

1 Answers1

0

To read a file you can easily use File.ReadAllLines, it will return a string array that contains each line of your file.

string[] lines = File.ReadAllLines("filepath");

Then you can use/manipulate these lines however you like.

Selman Genç
  • 100,147
  • 13
  • 119
  • 184