I’ve been trying to wrap my brain around this now for days,
and I’m getting nowhere, so please bear with me…

To Remove file on click of linkbutton I have below code:

aspx page:

<asp:LinkButton ID="RemovefileId" runat="server" CommandName="RemoveFile"  OnCommand="RemoveFilefunction" CommandArgument=<%#Eval("filepath")%>>LinkButton</asp:LinkButton>

aspx.cs page

protected void RemoveFilefunction(object sender, CommandEventArgs e)
 {
            string x = e.CommandArgument.ToString();//why Here x is empty string 
  //If U have any idea to delete file then help me..
  }

plz tell me any wrong in aspx file.

Recommended Answers

All 2 Replies

System.IO.File.Delete method.

for example,

file="~/samples/file.txt";
System.IO.File.Delete(MapPath(file));

I’ve been trying to wrap my brain around this now for days,
and I’m getting nowhere, so please bear with me…

To Remove file on click of linkbutton I have below code:

aspx page:

<asp:LinkButton ID="RemovefileId" runat="server" CommandName="RemoveFile"  OnCommand="RemoveFilefunction" CommandArgument=<%#Eval("filepath")%>>LinkButton</asp:LinkButton>

aspx.cs page

protected void RemoveFilefunction(object sender, CommandEventArgs e)
 {
            string x = e.CommandArgument.ToString();//why Here x is empty string 
  //If U have any idea to delete file then help me..
  }

plz tell me any wrong in aspx file.

............
i think in aspx page u made a mistake..
i have tried this code and i m getting the CommandArguement value..
Modification...u need to do..

CommandArgument='<%#Eval("filepath")%>'

i hope this modification will solve the problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.