How to delete images from temp folder i save images in MembershipUserId_abc.jpg format delete event is happen when user is logout i can global.asax please help me
global.asax.cs
protected void Session_End(object sender, EventArgs e) {
string uId = Membership.GetUser(Context.User.Identity.Name).ProviderUserKey.ToString(); //here i got an error Object reference not set to an instance of an object.
string path;
string[] filename;
path = System.Web.HttpContext.Current.Server.MapPath("~/temp/");
filename = Directory.GetFiles(path);
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) {
filepath.Delete();
// Session.Abandon();
}
}
}
}