There was such a problem: the code runs, but does not read the text file, much less create a new one. Tell me how you can change ...

public static void Main() { string path = @"NewFile.txt"; if (!File.Exists(path)) { string[] createText = { "Hello", "And", "Welcome" }; File.WriteAllLines(path, createText); } string[] readText = File.ReadAllLines(path); for (int i = 0; i < readText.Length; i++) { StringBuilder builder = new StringBuilder(); foreach (char ch in readText[i]) { if (Char.IsLetter(ch)) { if (Char.IsUpper(ch)) builder.Append(Char.ToLower(ch)); else builder.Append(Char.ToUpper(ch)); } else { builder.Append(ch); } } readText[i] = builder.ToString(); } File.WriteAllLines(path, readText); Console.ReadLine (); 

}

  • one
    I started it, everything works, they just missed it ; in string[] readText = File.ReadAllLines(path) and } at the end - RusArt
  • @RusArt corrected. Do you read the file and change the case? - user250204
  • @ Olga everything works, just checked, i.imgur.com/ZeislMD.png - Pavel Fedorov
  • @PavelFedorov, yes, I made sure everything works. - user250204
  • @PavelFedorov And then what should I add to the text he wrote in a new file? - user250204

0