Here I am going to explain, How can you Delete Files from Directory (Folder) Using Asp.Net.
Use the Below function for Delete Files from Directory (Folder).
protected void deletefiles()
{
string path = string.Empty;
path = "Image"; // Your Folder Name
if (Directory.Exists(HttpContext.Current.Server.MapPath(path)))
{
string[] files = System.IO.Directory.GetFiles(HttpContext.Current.Server.MapPath(path));
foreach (string file in files)
{
File.Delete(file);
}
}
}
Use the Below function for Delete Files from Directory (Folder).
protected void deletefiles()
{
string path = string.Empty;
path = "Image"; // Your Folder Name
if (Directory.Exists(HttpContext.Current.Server.MapPath(path)))
{
string[] files = System.IO.Directory.GetFiles(HttpContext.Current.Server.MapPath(path));
foreach (string file in files)
{
File.Delete(file);
}
}
}