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(.)

2 Answers2

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]
Manish Mishra
  • 12,163
  • 5
  • 35
  • 59
3

try the follwoing

 String FileExtension =System.IO.Path.GetExtension(FileUpload1.FileName); 
Ankush Jain
  • 1,532
  • 1
  • 15
  • 24