How to delete any file form the folder
protected void btnDelete_Click(object sender, EventArgs e)
{
string file_name = yourfilename;
string path = Server.MapPath("files//" + file_name);
FileInfo file = new FileInfo(path);
if (file.Exists)//check file exsit or not {
file.Delete();
lbl_output.Text = file_name + " file deleted successfully";
lbl_output.ForeColor = Color.Green;
}
else {
lbl_output.Text = file_name + " This file does not exists ";
lbl_output.ForeColor = Color.Red;
}}
I hope this will help you{
string file_name = yourfilename;
string path = Server.MapPath("files//" + file_name);
FileInfo file = new FileInfo(path);
if (file.Exists)//check file exsit or not {
file.Delete();
lbl_output.Text = file_name + " file deleted successfully";
lbl_output.ForeColor = Color.Green;
}
else {
lbl_output.Text = file_name + " This file does not exists ";
lbl_output.ForeColor = Color.Red;
}}