Below is the program which will create a file and write into it.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace File_simple_demo
{
class Program
{
static void Main(string[] args)
{
//System.IO.File.Create("e:\\abc.txt");
System.IO.Directory.CreateDirectory(@"e:\a1\a2\a3");
if (System.IO.File.Exists(@"e:\abc.txt"))
{
Console.WriteLine("File Already exists");
}
else
{
String str = "My Name is Scott, I am working in Google"; ;
System.IO.File.WriteAllText("e:\\abc.txt", str);
Console.WriteLine("File Created");
}
Console.ReadKey();
}
}
}
Comments
Post a Comment