How to delete uploaded images from Temp folder when user is logout using global.asax in asp.net
my global.asax.cs code please help me
protected void Session_End(object sender, EventArgs e) {
string uId = Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString();
string path;
string[] filename;
path = System.Web.HttpContext.Current.Server.MapPath(@"\Images");
filename = Directory.GetFiles(uId + "_" + path[path.Length - 1]);
for (int i = 0; i < filename.Length; i++) {
if (Session.SessionID == Path.GetFileName(filename[i])) {
string imgpath = filename[i];
FileInfo filepath = new FileInfo(imgpath);
if (filepath.Exists) {
File.Delete(Server.MapPath("~/temp/" + filepath.FullName));
Session.Abandon();
}
}
}
}