4

I am used in file upload control. i got the File Name for CreateDataBase.docx . Now I want the fileType for docx

I have CreateDataBase.docx .I just want this file type or i want to remove CreateDataBase

I have lot of file for xml,pdf,docx,etc . .So I want the file type or next characters of dot(.)

1

2 Answers 2

6

you can simply use

System.IO.Path.GetExtension(FileUpload1.FileName)

or you can simply perform

 string[] segments= FileUpload1.FileName.Split(".");
 string fileExt = segments[segments.Length-1]
3

try the follwoing

 String FileExtension =System.IO.Path.GetExtension(FileUpload1.FileName); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.