Hi
If you are uploading the images next time, then it should be saved in the different directory name right.
or Do you want to save all the images in the same directory
If you want to re-create the directory when you are saving the images next time to the directory.
You have to delete the directory which is existing. so, that you can re-create the directory with the same name.
I am explaining here to save the images in the same directory name.
if the directory is not exist, it creates the directory once.
Design Page
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btnSave" runat="server" Text="Save"
onclick="btnSave_Click" />
</asp:Content>
CS page:
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSave_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
if(!Directory.Exists(Server.MapPath("Images")))
{
Directory.CreateDirectory(Server.MapPath("Images"));
}
FileUpload1.SaveAs(Server.MapPath("Images\\"+FileUpload1.FileName));
}
}
}
Let me know, if you have any queries
Thanks & Regards,
Santhi .V
Raj.Trivedi, if this helps please login to Mark As Answer. | Alert Moderator