0
`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!";
    }`

and this is the error:

Access to the path 'D:\cms_vietnamnews_final\ToasoanTTXVN\Upload\Images\2018\9\19\' is denied.
Armali
  • 18,255
  • 14
  • 57
  • 171
  • I think the error message is somewhat self explanatory. Does said path exist and if so does your app pool have access to it? – JKerny Sep 19 '18 at 03:59
  • 1
    I think my app pool does not have to access to it. how to fix it? pls tell me – Huệ Còi Sep 19 '18 at 04:07
  • It might be slightly different dependent on your IIS version but something like this should get you out of trouble https://stackoverflow.com/questions/7334216/iis7-permissions-overview-applicationpoolidentity – JKerny Sep 19 '18 at 05:18

1 Answers1

0

It might be the App pool, and to fix it you need to login to Plesk and navigate to file [file manager] then select the folder you need and change the permissions by giving the [Application pool group ] the required permission.

enter image description here

Mohamed Hasan
  • 207
  • 4
  • 13