Why is access to the path denied?

前端 未结 29 1617
刺人心
刺人心 2020-11-22 15:25

I am having a problem where I am trying to delete my file but I get an exception.

if (result == \"Success\")
{
     if (FileUpload.HasFile)
     {
         t         


        
29条回答
  •  再見小時候
    2020-11-22 16:05

    I too faced the same problem when trying to do this after deployment at server:

    dirPath = Server.MapPath(".") + "\\website\\" + strUserName;
    if (!Directory.Exists(dirPath))
    {
        DirectoryInfo DI = Directory.CreateDirectory(dirPath);
    }
    string filePath = Server.MapPath(".") + "\\Website\\default.aspx";
    File.Copy(filePath, dirPath + "\\default.aspx", true);
    File.SetAttributes(dirPath + "\\default.aspx", FileAttributes.Normal);
    

    I granted permission in IIS to other group including administrator and my problem got solved.

提交回复
热议问题