I’m trying to change some text in a .CSV file.
StreamReader sReader = new StreamReader(path1);
while (sReader.Peek() != -1)
{
rowValue = sReader.ReadLine();
if (rowValue == "25")
{
sWriter = new StreamWriter(path1);
rowValue = "27";
sWriter.WriteLine(rowValue);
}
}
Nothing happened. What is the correct way, please?
You can easily accomplish this task with System.IO.File.ReadAllLines and System.IO.File.WriteAllLines