Error wanting to delete an image in a folder in ASP.NET - VB

0

--- EDITED

I have already corrected some things and now it throws me the following error message .. as if I did not have permissions to access that folder where the images are:

Access denied to the path

File.Delete(MapPath(e.CommandArgument.ToString()))

/////////////////////////////////////////////// ////////////////////////////////////////////////

Dear, I am programming in ASP.NET VB for the first time, I am currently creating a system that allows me to load and delete images in a certain folder, the load works, but when wanting to delete it throws me the following error message : Can not convert an object of type 'System.EventArgs' to type 'System.Web.UI.WebControls.CommandEventArgs'.

Source code error:

Width="156px" BorderWidth="2px" ImageUrl='<%# Eval("path") %>' />
<br />
<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Command" 
Text='<%# Eval("path") %>' oncommand="LinkButton1_Command"></asp:LinkButton>
</ItemTemplate>

The error marks it in the line that is after the.

I delete the image with the following code:

Protected Sub LinkButton1_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
        File.Delete(MapPath(e.CommandArgument.ToString()))
        Response.Write("Imagen eliminada satisfactoriamente")
    End Sub
    
asked by Francisco 14.08.2017 в 19:00
source

0 answers