get file extension in csharp file upload

Code Example - get file extension in csharp file upload

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

csharp get file extension

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

Related code examples