Try this - It works correctly
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"; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)