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


sagar Bhosale162 reputationPosted Jun 16, 2011, 5:26 PM EDT
Suthish NairRank #92 · 22.8K reputationPosted Jun 16, 2011, 7:34 PM EDT
Pradeep ChandrakerRank #941 · 2.2K reputationPosted Jun 16, 2011, 8:11 PM EDT
Suthish NairRank #92 · 22.8K reputationPosted Jun 17, 2011, 2:52 AM EDT
Pradeep ChandrakerRank #941 · 2.2K reputationPosted Jun 17, 2011, 5:40 AM EDT
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.
sagar Bhosale162 reputationPosted Jun 17, 2011, 5:56 AM EDT
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 Bhosale162 reputationPosted Jun 17, 2011, 5:57 AM EDT
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
Suthish NairRank #92 · 22.8K reputationPosted Jun 17, 2011, 11:34 AM EDT
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
Suthish NairRank #92 · 22.8K reputationPosted Jun 18, 2011, 12:24 AM EDT