Wednesday, February 3, 2010

Delete History i .Net

namespace
{

DeleteHistory /// 

/// Summary description for Delete_History.

/// 

{





{

public class Delete_History : System.Web.UI.Pageprotected System.Web.UI.WebControls.ListBox LstHistory;protectedSystem.Web.UI.WebControls.Button Btn_Clr_History;string path;private void Page_Load(object sender, System.EventArgs e)// Put user code to initialize the page here
path = Environment.GetFolderPath(Environment.SpecialFolder.History) + "\\";
GetList(path);
}

#region

{

Web Form Designer generated codeoverride protected void OnInit(EventArgs e)//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//
InitializeComponent();

}


base.OnInit(e);/// 

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// 

{


}
private void InitializeComponent()this.Btn_Clr_History.Click += newSystem.EventHandler(this.Btn_Clr_History_Click);this.Load += new System.EventHandler(this.Page_Load);
#endregion

{
DirectoryInfo dir =
DirectoryInfo[] dirs = dir.GetDirectories();
FileInfo[] files = dir.GetFiles();

{
GetList(d.FullName);
}

{
LstHistory.Items.Add(f.FullName);
}
}

{

{

public void GetList (string thePath)new DirectoryInfo(thePath);foreach(DirectoryInfo d in dirs)foreach(FileInfo f infiles)public void ClrHistory()for(int i = 0 ; i < LstHistory.Items.Count ; i ++ )try
{
File.Delete(LstHistory.Items[i].Text);
}

{
Response.Write("Error :" + e.Message);

}
}
}

{
ClrHistory();
}
}
}
catch(IOException e)private void Btn_Clr_History_Click(object sender, System.EventArgs e)

No comments:

Post a Comment