I am able to delete the data from database. My Problem is how to delete a file from the folder that is linked to the database using c#, asp.net. Below is my code snippet for your reference. I would greatly appreciate your help/suggestion.
Thank you.

protected void lnkdelete_Click(object sender, EventArgs e)

        LinkButton lnkbtn = sender as LinkButton;
        //getting particular row linkbutton
        GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
        //getting userid of particular row
        int id = Convert.ToInt32(gvrecords.DataKeys[gvrow.RowIndex].Value.ToString());
        string username = gvrow.Cells[0].Text;
        MySqlCommand cmd = new MySqlCommand("delete from file_info where id=" + id, MySqlConn);
        int result = cmd.ExecuteNonQuery();

       // File.Delete(@"E:\uploadfiles\test.txt"); 

        if (result == 1)
            //Displaying alert message after successfully deletion of user
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:alert('" + username + "'s files deleted successfully')", true);

what error are you getting when you run this code? Or have you not figured out how to get the file name to delete? If not, you would have to query the database before doing the deletion so you have the name of the file to delete then run the delete query and the file.delete method.

This article has been dead for over six months. Start a new discussion instead.