parse text file in C#


/ Published in: C#
Save to your folder(s)

found this on a forum comment thought it would be useful


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.