static void Main(string[] args)
{
Console.WriteLine("Enter full file name with path:");
string strFileName = Console.ReadLine();
string FileEx =Path.GetExtension(strFileName);
Console.WriteLine("Your File Extension is {0}",FileEx);
}
output :
Enter full file name with path:
D:\MyFiles\TestFile.csv
Your File Extension is .csv
Here I have a problem if I saved a text file in name of TestFile.csv it shows file extension is csv but I really want actual file extension even if given a fake file name
Eg : TestFile.csv ( Type of text file ) should give .txt output TestFile.csv ( Type of csv file) should give .csv output
I think it is not possible to attain this using above Function , any valuable advice will be helpful.
Thanks in advance