Hi,
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;
MySqlConn.Open();
MySqlCommand cmd = new MySqlCommand("delete from file_info where id=" + id, MySqlConn);
int result = cmd.ExecuteNonQuery();
MySqlConn.Close();
// File.Delete(@"E:\uploadfiles\test.txt");
if (result == 1)
{
BindFileDetails();
//Displaying alert message after successfully deletion of user
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:alert('" + username + "'s files deleted successfully')", true);
}
}