CodeToLive

File Handling

File handling in C# allows you to read from and write to files using the System.IO namespace.

Reading from a File


string path = "example.txt";
string content = File.ReadAllText(path);
Console.WriteLine(content);
      

Writing to a File


string path = "example.txt";
string content = "Hello, World!";
File.WriteAllText(path, content);
      
Next: LINQ