string path = @"C:\example\newfile.txt"; File.Create(path);
string path = @"C:\example\filetodelete.txt"; File.Delete(path);
string path = @"C:\example\filetoread.txt"; string text = File.ReadAllText(path); Console.WriteLine(text);
string path = @"C:\example\filetowrite.txt"; string text = "Hello, world!"; File.WriteAllText(path, text);This code writes the specified text to the specified file, replacing any existing content. Package Library: This class is a part of the .NET Framework, so it is available in all versions of .NET.