protected void Button1_Click (object sender, EventArgs e) {string filename = this. dropdownlist1.selectedvalue;//Final Name if (this.) Fileupload1.postedfile! = null) {string basefilename = this. fileupload1.postedfile.filename;//get upload file filename int i = Basefilename.lastindexof ("."); String ext = basefilename.substring (i);//Gets the file extension string savepath = Server.MapPath ("~/pic/"); if (! System.IO.Directory.Exists (Savepath)) {System.IO.Directory.CreateDirectory (Savepath);} Savepath = Savepath + "\ \" + Fi Lename+ext; Response.Write (EXT); if (!ext. Equals (". jpg") &&!ext. Equals (". jpeg") &&!ext. Equals (". bmp") &&!ext. Equals (". gif") &&!ext. Equals (". png")) {Response.Write ("The upload file format is incorrect!) <a href= "\" href= "\" "Upload.aspx\" > re-upload </a> "); Response.End (); } FileUpload1.PostedFile.SaveAs (Savepath); } }