With the FileInfo class, you can create new files, access information about the files, delete, and move files. This class also provides methods for opening, reading from, and writing to a file.
Console Application
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace pr5
{
class Program
{
static void Main(string[] args)
{
FileInfo fi = new FileInfo(@"C:\Documents and Settings\admin\Desktop\SD\Myprogram.txt");
FileStream fstr = fi.Create();
Console.WriteLine("Creation Time: {0}", fi.CreationTime);
Console.WriteLine("Full Name: {0}", fi.FullName);
Console.WriteLine("FileAttributes: {0}", fi.Attributes.ToString());
//Way to delete Myprogram.txt file.
Console.WriteLine("Press any key to delete the file");
Console.Read();
fstr.Close();
fi.Delete();
}
}
}