Wednesday, December 30, 2009

Delete Cookies

In this code the header files and assembly files are same as Delete Cache which i post early

and the code is:

//textBox is used for deleting particular Cookies

string enteredtext = txt_url.Text.Trim();
string lowertext = txt_url.Text.ToLower();
string uppertext = txt_url.Text.ToUpper();

string[] cookiefile = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Cookies), "*", SearchOption.AllDirectories);
for (int i = 0; i < cookiefile.Count(); i++)
{
try
{
if (cookiefile.ElementAt(i).Contains(enteredtext) || cookiefile.ElementAt(i).Contains(lowertext) || cookiefile.ElementAt(i).Contains(uppertext))
{
File.Delete(cookiefile.ElementAt(i));
lbl_message.Text = "Cookie cleared";
}

}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

No comments:

Post a Comment