How to create Folder in Remote Location
Right now I have this code which creates a folder in the specified path..
protected void btnAdd_Click(object sender, EventArgs e)
{
albname = txtName.Text.ToString();
try
{
string targetPath = Server.MapPath("..//Images//Albums//" +
albname);
if (!System.IO.Directory.Exists(targetPath))
{
System.IO.Directory.CreateDirectory(targetPath);
id = id + 1;
con.Open();
com = new SqlCommand("insert into album values(" + id +
",'" + albname + "')", con);
com.ExecuteNonQuery();
Page.ClientScript.RegisterStartupScript(GetType(),
"msgbox", "alert('Album Successfully added');", true);
con.Close();
txtName.Text = "";
}
else
{
Page.ClientScript.RegisterStartupScript(GetType(),
"msgbox", "alert('Album Name Already Exists!Please enter a
different Name');", true);
}
}
catch (Exception ne)
{
error.Visible = true;
lblError.Text = ne.ToString();
}
}
This works well and fine for me now.. It creates a folder in specified
path.. Now I am running this website in Localhost.. now when I host
website in any server does the above code work?? or do is there any
different way to create a folder when my website is Live on Internet..
Hope I will get any beautiful solution.
No comments:
Post a Comment