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 history file
string enteredtext = txt_url.Text.Trim();
string lowertext = txt_url.Text.ToLower();
string uppertext = txt_url.Text.ToUpper();
string[] historyfile = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.History), "*", SearchOption.AllDirectories);
for (int i = 0; i < historyfile.Count(); i++)
{
try
{
File.Delete(historyfile.ElementAt(i));
lbl_message.Text = historyfile.ElementAt(i)+ " cleared";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
//this is the function which I used :
public void GetHistory()
{
historylinks.Clear();
using (RegistryKey tempKey = Registry.CurrentUser.OpenSubKey(REG_URL))
{
if (tempKey == null)
{
using (RegistryKey tempKeyShort = Registry.CurrentUser.OpenSubKey(REG_URL_SHORT, true))
{
if (tempKeyShort == null)
{
MessageBox.Show("The registry entry for " + REG_URL_SHORT + " does not exist!",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
else
{
tempKeyShort.CreateSubKey("TypedURLs", RegistryKeyPermissionCheck.ReadWriteSubTree);
}
}
}
}
using (RegistryKey tempKey = Registry.CurrentUser.OpenSubKey(REG_URL))
{
if (tempKey == null)
{
System.Windows.Forms.MessageBox.Show("The registry entry for " + REG_URL + " does not exist!",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string[] vals = tempKey.GetValueNames();
int itemcounter = 0;
foreach (string url in vals)
{
object keyValue = tempKey.GetValue(url);
if (keyValue != null)
{
histlink hl = new histlink();
string entry = keyValue.ToString();
if (entry.Length != 0)
{
itemcounter++;
hl.Entry = entry;
hl.URL = url;
historylinks.Add(itemcounter, hl);
}
}
}
}
No comments:
Post a Comment