Click here to Skip to main content
15,907,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys, i have a FileUpload control and Button. when clicking on the fileupload control i want getting only .txt and .doc files.

Please any one help.
Posted

 
Share this answer
 
Try this - It works correctly

C#
if (fileUpload.HasFile)
{
System.IO.FileInfo sr = new System.IO.FileInfo(Server.MapPath(fileUpload1.FileName));
     if (sr.Extension == ".txt")
     {
         //Your Code to Save File
     }  
     else
     {
         lblStatus.Text="Select txt File";
     }
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900