I did something like the following code:
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Session["loginid"].ToString();
}
protected void delete_click(object sender, EventArgs e)
{
delete("mail1",Session["loginid"]);
}
private int delete(string mailid, string user)
{
System.IO.Directory.Delete(Server.MapPath(@"~\files\" + user + @"\" + mailid), true);
}
When I click the delete button, everything works fine and the folder is deleted. but after that, when the page returns again, NullRefrenceException Label1.Text = Session ["loginid"] exception. ToString ();
Why is this happening...??
When I do not use this Directory.Delete () method, everything works fine and the session variables are not null.
When I traced my application, I found that after the Directory.Delete () method, the session variables were intact, and I was able to use these session variables in processing after Directory.Delete ().
, null.
, delete().
, , .
Visual Studio.
, .