Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 21st, 2012  |  syntax: None  |  size: 1.33 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Extracting specific data from a file
  2. using (StreamReader sr = new StreamReader("TabDelimited.txt"))
  3.  {
  4.       string line;
  5.       // Read and display lines from the file until the end of
  6.       // the file is reached.
  7.       while ((line = sr.ReadLine()) != null)
  8.       {
  9.           int idx = line.IndexOf(' ');
  10.           if (idx < 0)
  11.              continue;
  12.  
  13.           // get the uid
  14.           string uid = line.Substring(0, idx - 1);
  15.       }
  16.  }
  17.        
  18. using (StreamReader sr = new StreamReader("TabDelimited.txt"))
  19.  {
  20.       string line;
  21.       // Read and display lines from the file until the end of
  22.       // the file is reached.
  23.       while ((line = sr.ReadLine()) != null)
  24.       {
  25.           int idx = line.IndexOf(' ');
  26.           if (idx < 0)
  27.              continue;
  28.  
  29.           // get the uid
  30.           string uid = line.Substring(0, idx - 1);
  31.       }
  32.  }
  33.        
  34. using (StreamReader sr = new StreamReader("TabDelimited.txt"))
  35.  {
  36.       string line;
  37.       // Read and display lines from the file until the end of
  38.       // the file is reached.
  39.       while ((line = sr.ReadLine()) != null)
  40.       {
  41.           int idx = line.IndexOf(' ');
  42.           if (idx < 0)
  43.              continue;
  44.  
  45.           // get the uid
  46.           string uid = line.Substring(0, idx - 1);
  47.       }
  48.  }
  49.        
  50. string [] strArray = File.ReadAllLines(path);
  51. string [] line1 =strArray[0].Split(' ');