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

Suthish NairPosted Jun 18, 2011, 4:24 AM
Suthish NairPosted Jun 17, 2011, 3:34 PM
He was talking about System Temp folders, now explained correctly with project folder.
Sagar,
I given a reply to your other thread, try at your end.
http://www.c-sharpcorner.com/Forums/Thread/127863/how-to-delete-image-according-to-intial-string-of-the-im.aspx
sagar BhosalePosted Jun 17, 2011, 9:57 AM
so my problem is that how to delete that images according that userid
using foreach loop how i collect images according to userid then matching that userid how i will delete images pleaz help me i very trouble to find out solution
i want to my code in above format how can i do this pleaz help me
my code is global.asax.cs
protected void Session_End(object sender, EventArgs e) {
Without specifying uploaded imagepath how i will delete image according to userid from temp folder how to write code pleaz help me i am very difficult situation lplease give me code for this
sagar BhosalePosted Jun 17, 2011, 9:56 AM
so my problem is that how to delete that images according that userid
using foreach loop how i collect images according to userid then matching that userid how i will delete images pleaz help me i very trouble to find out solution
i want to my code in above format how can i do this pleaz help me
my code is global.asax.cs
protected void Session_End(object sender, EventArgs e) {
Without specifying uploaded imagepath how i will delete image according to userid from temp folder how to write code pleaz help me i am very difficult situation lplease give me code for this
Pradeep ChandrakerPosted Jun 17, 2011, 9:40 AM
I understood what your are saying. But what I was trying to explain is talking about system temporary folder is irrelevant to this thread, as @Sagar is using System.Web.Hosting.HostingEnvironment.MapPath which maps application virtual path with physical path. It doesn't map virtual path with system temporary folder. It is just he has "temp" folder in his application root directory.
Anyway as @Sagar has found solution no more discussion is needed.
Suthish NairPosted Jun 17, 2011, 6:52 AM
Pradeep ChandrakerPosted Jun 17, 2011, 12:11 AM
Suthish NairPosted Jun 16, 2011, 11:34 PM
sagar BhosalePosted Jun 16, 2011, 9:26 PM