Getting Started - FileAccess

CSharp · Console

/Program.cs

using System;
using System.IO;
					
public class Program
{
	public static void Main()
	{
		var fileName = "filename.txt";
		
		// CREATE a file in your Sandbox using .NET Fiddle 
		WriteFile(fileName);
		
		// READ an existing file in your Sandbox using .NET Fiddle
		var s = ReadAllText(fileName);
		
		Console.Write(s);
	}
	
	public static void WriteFile(string path)
	{
		File.WriteAllText(path, ".NET Fiddle is AWESOME!!!");
	}
	
	public static string ReadAllText(string path)
	{
		return File.ReadAllText(path);
	}
}
;