Try using Server.MapPath
as follow
string rootPath = Server.MapPath(fileNode.Text);
Directory.CreateDirectory(rootPath + "/" + txtDirName.Text);
More detail about server.mappath
Question
Here is my code to create Directory. It Works on local-end but if I host this web app then will get the ERROR MESSAGE : PATH NOT FOUND
try
{
if (tvFolders.SelectedNode != null)
{
TreeNode fileNode = new TreeNode();
fileNode.Text =Server.MapPath("~//"+ tvFolders.SelectedValue.ToString());
string rootPath = fileNode.Text;
Directory.CreateDirectory(rootPath + "/" + txtDirName.Text);
lblMessage.Text = "Directory created";
}
else
lblMessage.Text = "Directory already exists";
}
catch (Exception)
{
}
Solution
Try using Server.MapPath
as follow
string rootPath = Server.MapPath(fileNode.Text);
Directory.CreateDirectory(rootPath + "/" + txtDirName.Text);
More detail about server.mappath