In this post i will going to show how to delete file and image from the folder or directory using asp.net c#.
Add the following button code in asp web page
<asp:Button ID="btnDeleteFile" runat="server" Text="Delete" OnClick="btnDeleteFile_Click"/>
Add definition of btnDeleteFile_Click in cs file of web page
protected void btnDeleteFile_Click(object sender, EventArgs e)
{
string FolderPath ="";
//set the folder path where files are exists
FolderPath += "Uploads/10_New_file_1.jpg";
string path = Server.MapPath(FolderPath);
FileInfo file = new FileInfo(path);
if (file.Exists)//check file exsit or not
{
file.Delete();
}
}