Click here to Skip to main content
15,905,028 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
protected void LinkButtondelete_Command(object sender, CommandEventArgs e)
        {
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));
            }
}


What I have tried:

<asp:LinkButton ID="LinkButtondelete" runat="server" CommandArgument='<%# Eval("id") %>' CommandName="Select" CausesValidation="false"
                                         OnCommand="LinkButtondelete_Command">Delete</asp:LinkButton>
Posted
Updated 19-Sep-18 3:05am
Comments
Dave Kreskowiak 18-Sep-18 23:07pm    
Did you plan on telling us the error message?
huekoi13597 18-Sep-18 23:09pm    
Access to the path 'D:\cms_vietnamnews_final\ToasoanTTXVN\Upload\Images\2018\9\19\' is denied.
here is the error
phil.o 19-Sep-18 1:47am    
Check the security settings on relevant folder ; there may be some rights missing for the account under which is running the application pool driving your website.
huekoi13597 19-Sep-18 2:43am    
thank you

1 solution

You need to set the permissions on the folder you're deleting from so, that identity used for running your webservice is allowed to delete files there.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900