It should be more like this:
foreach (string line in File.ReadAllLines("C:\\TESTDATA.txt"))
{
string line1;
line1 = line.Replace("\t", "");
line1 = line1.Replace("\r", "");
line1 = line1.Trim();
line1 = line1.Replace(" ", "");
}
Of course, it goes without saying that you have to actually *do something* (such as write
to a file) with the string "line1" before leaving that foreach code block or it will be
lost (destroyed when it goes out of scope).
- Wayne
No comments:
Post a Comment