Syntax:
string DirectoryInfo.Extension
Program:
using System;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
DirectoryInfo d = new DirectoryInfo("sample.txt");
Console.WriteLine("File extension is : " + d.Extension);
}
}
}
Output:
File extension is : .txt