This code sample will give you the file extension from full file path. Sometimes we need to get the extension from the path for eg. if you need to validate the file extension to upload the files or move only the file with particular file extension. like only .gif or jpg only you want to upload than you can use GetExtension() method of Path class from System.IO namespace
string fileName = Path.GetExtension(@"c:\MyFolder\MyFile.txt");
Response.Write(fileName);
and the result will be
.txt