Here is the sample code for clearing temporary internet foder by using C# in winforms.
private void btnClear_Click(object sender, EventArgs e)
{
ClearAll(new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)));
MessageBox.Show("Your temporary files has been cleaned.! ");
}
public void ClearAll(DirectoryInfo dirInfo)
{
foreach (FileInfo fileInfo in dirInfo.GetFiles())
{
try
{
fileInfo.Delete();
}
catch { }
}
foreach (DirectoryInfo subDirectory in dirInfo.GetDirectories())
{
ClearAll(subDirectory);
}
}
...S.VinotkumaR.