C# program to get extension of a given file
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
Table of Contents