I have code that is supposed to replace the word "simple" with the word "word" within all text files in the given directly, but I do not know what to correct in order for the code to work.
static void Main(string[] args)
{
// Например, получаем все файлы определённого типа в заданной директории.
string[] fileList = Directory.GetFiles(@"C:/Users/Users/Desktop/a/","*.txt");
foreach (var filePath in fileList) // Для каждого пути файла...
{
for (int i = 0; i < filePath.Length; i++)
{
var lines = File.ReadAllText(filePath);
lines = lines.Replace("simple", "word");
File.WriteAllText(filePath, lines);
}
}
}