Author:

I am a web developer. I work on JavaScript, PHP, ASP.NET, jQuery, ActionScript, AJAX and Facebook application, as well as interested in social networking and daily active user on Twitter, Facebook and Google+

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.


Kick It on DotNetKicks.com   Shout it  

Popularity: 8%

Comments on this entry (3 comments)

Did you like this post? You can share your opinion with us! Simply click here.

Top Mattress

Great! thanks for the share!
Arron

Reply
Oscar

Gracias me fue muy util

Reply

su bienvenida (Your welcome)

Add Your Comment