从文件夹删除图像时出现错误

时间:2018-09-19 03:47:41

标签: asp.net

`protected void LinkButtondelete_Command(object sender, CommandEventArgs e)
    {
        int macv = 0;
        if (Page.Request.Params["id"] != null)
            macv = int.Parse(Page.Request.Params["id"]);
        if (macv != 0)
        {
            string sqldelete = "delete from T_CongViec_Attach where MaAttachFile=" + e.CommandArgument.ToString() + " and MaCV=" + macv;
            ulti.ExecSqlDataSet(sqldelete);
        }
        else
        {
            string sqldelete = "delete from T_Attachfile_CV where id=" + e.CommandArgument.ToString();
            ulti.ExecSqlDataSet(sqldelete);
        }
        foreach(DataListItem item in DataListAttachfile.Items)
        {
                string vitualpath = System.Configuration.ConfigurationManager.AppSettings["UploadPath"].ToString() + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/" + att.Duongdanfile;
                string savepath = HttpContext.Current.Server.MapPath("/" + vitualpath);                    
                File.Delete(MapPath(vitualpath));
        }
        show_data(macv);
        lblMessage.Text = "Delete successffully!";
    }`

这是错误:

Access to the path 'D:\cms_vietnamnews_final\ToasoanTTXVN\Upload\Images\2018\9\19\' is denied.

1 个答案:

答案 0 :(得分:0)

它可能是应用程序池,要修复它,您需要登录到Plesk并导航到文件[文件管理器],然后选择所需的文件夹并通过为[应用程序池组]授予所需的权限来更改权限。

enter image description here