Delete all files method is being used when you store uploaded temporary files in specific folder and want to remove all now. Here I am showing very easy and little method which will definitely help you out.
Delete All Files Method – C#
public void DeleteAllTempFiles()
{
foreach (var f in System.IO.Directory.GetFiles(Server.MapPath("~/temp")))
System.IO.File.Delete(f);
}
Delete All Files Method – VB.NET
Public Function DeleteAllTempFiles()
For Each f As var In System.IO.Directory.GetFiles(Server.MapPath("~/temp"))
System.IO.File.Delete(f)
Next
End Function
In the above method I am trying to delete all files which I stored in the “temp” folder. You can create this method to call Scheduler Task as well.
Thanks you.
Popularity: 8%





Comments on this entry (3 comments)
Did you like this post? You can share your opinion with us! Simply click here.