string myFilePath = @"C:\MyFile.txt"; string ext = Path.GetExtension(myFilePath); // ext would be ".txt"
string extension=System.IO.Path.GetExtension(file1.FileName);