FileInfo Class in C#
In this article we will discuss about what is FileInfo Class in C# and how it will be used in C#.
This Class contains non-static methods which means these methods will be called by the object of the Class. So, we need to create the object of the Class. This Class resides inside the System.IO namespace. This Class cannot be inherited. This Class provides the various methods to perform operation on the File like AppendText, Create, Exists, Encrypt, Decrypt etc.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace absclass
{
class Program
{
static void Main(string[] args)
{
FileInfo finfo=new FileInfo("D:\\Megha\\meesha.txt");
finfo.Delete();
Console.WriteLine("File deleted");
Console.ReadLine();
}
}
}
|
Output:
Here we have seen that we have create the object of the FileInfo Class .i.e. finfo and through it we have call the delete method of the FileInfo Class.
Further Readings
You may also want to read these related articles.
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here