Friday, July 6, 2012

Save file onto a folder(on solution) while upload

 //To Save the file
string test = Server.MapPath("~/Files/");
FileUpload1.PostedFile.SaveAs(test + FileUpload1.PostedFile.FileName);
//To delete the file
//add System.IO namespace for the "File" attribute
File.Delete(Server.MapPath("~/Files/" + FileUpload1.PostedFile.FileName));




<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btnUpload" runat="server" Text="Button" onclick="btnUpload_Click" />

No comments:

Post a Comment