You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
690 B
C#

/*
* C# Program to Create a File
*/
using System;
using System.IO;
using System.Text;
class Test
{
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)
{
Console.WriteLine(s);
}
}
Console.Read();
}
}
/*
File is Created