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

Untitled

By: a guest on Jun 30th, 2012  |  syntax: None  |  size: 0.80 KB  |  hits: 17  |  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. C# Text Reader and Writer
  2. string t = File.ReadAllText(path);
  3.  
  4.         t = t.Replace('=', ' ');
  5.         t = t.Replace("rnrn", ",");
  6.         t = t.Replace("rn", ",");
  7.         t = t.Replace("n", ",");
  8.         t = t.Replace("  ", " ");
  9.        
  10. using (TextReader textReader = ...)
  11. using (TextWriter textWriter = ...)
  12. {
  13.     string line;
  14.  
  15.     while ((line = textReader.ReadLine()) != null)
  16.     {
  17.         // split into columns here
  18.         string[] columns = ...;
  19.  
  20.         foreach (string column in columns)
  21.         {
  22.             textWriter.WriteLine(column);
  23.         }
  24.     }
  25. }
  26.        
  27. string data = File.ReadAllText( path );
  28. string[] lines = data.Split('t'); //I assume that "columns" mean tab seperated
  29. File.WriteAllLines( path2, lines );
  30.        
  31. File.WriteAllLines( destinationPath, File.ReadAllText( sourcePath ).Split('t') );