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();
}
}
}
}


Suthish NairRank #92 · 22.8K reputationPosted Jun 14, 2011, 2:04 AM EDT
sagar Bhosale162 reputationPosted Jun 14, 2011, 2:15 AM EDT
Suthish NairRank #92 · 22.8K reputationPosted Jun 14, 2011, 2:27 AM EDT
System.IO.Path.GetTempFileName() will give you the temp folder with files. You needs to do if (File.Exists(sFileNamePath)) { File.Delete(sFileNamePath); }sagar Bhosale162 reputationPosted Jun 14, 2011, 2:41 AM EDT
Suthish NairRank #92 · 22.8K reputationPosted Jun 14, 2011, 2:52 AM EDT
Session.Abandon method destroys all the objects stored in a Session object and releases their resources. You need write separate logic to delete the physical files.
Suthish NairRank #92 · 22.8K reputationPosted Jun 18, 2011, 12:23 AM EDT