
Untitled
By: a guest on
Jun 30th, 2012 | syntax:
None | size: 0.80 KB | hits: 17 | expires: Never
C# Text Reader and Writer
string t = File.ReadAllText(path);
t = t.Replace('=', ' ');
t = t.Replace("rnrn", ",");
t = t.Replace("rn", ",");
t = t.Replace("n", ",");
t = t.Replace(" ", " ");
using (TextReader textReader = ...)
using (TextWriter textWriter = ...)
{
string line;
while ((line = textReader.ReadLine()) != null)
{
// split into columns here
string[] columns = ...;
foreach (string column in columns)
{
textWriter.WriteLine(column);
}
}
}
string data = File.ReadAllText( path );
string[] lines = data.Split('t'); //I assume that "columns" mean tab seperated
File.WriteAllLines( path2, lines );
File.WriteAllLines( destinationPath, File.ReadAllText( sourcePath ).Split('t') );