这是我创建目录的代码。它适用于本地端,但如果我托管此Web应用程序,则会获得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)
{
}
答案 0 :(得分:0)
尝试使用Server.MapPath
,如下所示
string rootPath = Server.MapPath(fileNode.Text);
Directory.CreateDirectory(rootPath + "/" + txtDirName.Text);
有关server.mappath
的更多详细信息