Posted By

itinko on 10/10/10


Tagged

parse text


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

franksmile0310
Tyster
Priestd09
danfinrud55


parse text file in C#


 / Published in: C#
 

found this on a forum comment thought it would be useful

  1. StreamReader reader = new StreamReader(filePath);
  2. string line;
  3.  
  4. //Assume that is a tab, if space change to " ".ToCharArray()
  5. char[] splitChar = "\t".ToCharArray();
  6.  
  7. while(null != (line = reader.ReadLine))
  8. {
  9. string[] split = line.Split(splitChar);
  10.  
  11. int bit= int.Parse(split[0]);
  12. string name = split[1];
  13. string description = split[2];
  14.  
  15. //Do something with parse here?
  16. }
  17.  
  18. reader.Dispose();

Report this snippet  

You need to login to post a comment.