我在创建目录时遇到问题:
if (!Directory.Exists(directorypath)//here i have that problem not enter into if contion
{
Directory.CreateDirectory(directorypath);
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Successfully Saved');", true);
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Directory Already Exists');", true);
}
答案 0 :(得分:0)
你能这样做吗?
try
{
if (!Directory.Exists(directorypath))
{
Directory.CreateDirectory(directorypath);
ClientScript.RegisterStartupScript(this,this.GetType(), "alert", "alert('Successfully Saved');", true);
}
else
{
ClientScript.RegisterStartupScript(this,this.GetType(), "alert", "alert('Directory Already Exists');", true);
}
}
catch(Exception ex)
{
throw;
}
我相信你在第一行有问题,请确保directorypath
有有效路径