csharp get file extension

Code Example - csharp get file extension

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

get file extension in csharp file upload

                        
                                string extension=System.IO.Path.GetExtension(file1.FileName);