when i execure the code for delete a folder then the session became null?
why?
code for delete the folder here
DirectoryInfo thisThumnials = new DirectoryInfo(Server.MapPath("../Albums/" + categoryID + "/Images/" + "/ThumnailImages"));
DeleteFolder(thisThumnials);
public void DeleteFolder(DirectoryInfo df)
{
try
{
if (df.Exists)
{
foreach (FileInfo fi in df.GetFiles())
{
fi.Delete();
}
if (df.Exists)
{
df.Delete();
}
}
}
catch
{
}
}
Loading

Abhimanyu K VatsaPosted Aug 1, 2011, 4:14 AM
lots of discussions i made when i where struggling with this issue. look, as i know there is no any straight-forward method (look microsoft feedback section) for such issue read this. however, we have couple of ways to overcome this issue.
first, if deleting folder is making problem then don't create the folder inside application root.
second, look at this
Zoran HorvatPosted Aug 1, 2011, 3:52 AM
So you have resolved your own question.
Zoran HorvatPosted Aug 1, 2011, 3:48 AM
Session["Test"] = "Test_variable";
try
{
DirectoryInfo thisThumnials = new DirectoryInfo(Server.MapPath("../Albums/" + categoryID + "/Images/" + "/ThumnailImages"));
thisThumnials.Delete(true);
}
catch
{
}
string test = (string)Session["Test"];
Response.Write(test ?? "
Zoran
Vikas AhlawatPosted Aug 1, 2011, 3:36 AM
http://stackoverflow.com/questions/638668/delete-directory-from-asp-net-application-returns-to-new-session
I got that when we delete any directery then all session will clear.
is there any solution of my problem?
Zoran HorvatPosted Aug 1, 2011, 3:35 AM
Another question is how long does this code execute? If it is very long operation and session expiration is set to very short time then session would naturally expire.
Please provide more information about the code being executed.
Zoran