You can Copy below code and paste in your code file.
//-----------------------Code Start here----------------------------
protected void CleanImageFolder()
{
string imgFolder = Server.MapPath("~/lab/maskemail/img/");
string[] imgList = Directory.GetFiles(imgFolder, "*.jpg");
foreach (string img in imgList)
{
FileInfo imgInfo = new FileInfo(img);
if (imgInfo.LastWriteTime < DateTime.Now.AddMinutes(-3))
{
imgInfo.Delete();
}
}
}
//-----------------------Code End here----------------------------
Hope this post will help you,
Rajesh Singh
Asp.Net Developer
Indianic Infotech Ltd (India)
Rajesh@indianic.com
Subscribe to:
Post Comments (Atom)
Post a Comment