Here is source code of the C# Program to Create a File. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
* C# Program to Create a File
public static void Main()
string textpath = @"c:\sri\test.txt";
using (FileStream fs = File.Create(textpath))
Byte info = new UTF8Encoding(true).GetBytes("File is Created");
fs.Write(info, 0, info.Length);
using (StreamReader sr = File.OpenText(textpath))
string s = "";
while ((s = sr.ReadLine()) != null)
Here is the output of the C# Program:
File is Created
Sanfoundry Global Education & Learning Series – 1000 C# Programs.