What i am trying to do is get the number of files in a specific directory and add that in .csv file with the computer name. (which is done). What i can't do is read the file first, if computer name already exists, it should change the corresponding values. There are five fields in .csv file. I want to find and replace the rest of the changed values on the basis of first field i.e. the name of computer.
Is there a way to probably make a search pattern to replace.
if (File.ReadAllText(filepath).Contains(compName))
{
var s = File.ReadAllText(filepath);
s = s.Replace(compName, fileText.ToString());
File.WriteAllText(filepath, s);
}
else
{
File.AppendAllText(filepath, fileText);
}