how to clear all cookies/cache for IE browser using C# code/.NET

Hi,

I want to clear all the cookies/cache from the IE browser using Visual C# code.

Can any1 plz provide me code for it?

- Dev
dev_qasourceAsked:
Who is Participating?
 
ashokpumcaConnect With a Mentor Commented:
Check this code, hope this will help..

using System.IO;
void clearIECache()
{
   ClearFolder (new DirectoryInfo (Environment.GetFolderPath
      (Environment.SpecialFolder.InternetCache)));
}
 
void ClearFolder (DirectoryInfo folder)
{
   foreach (FileInfo file in folder.GetFiles())
      { file.Delete(); }
   foreach (DirectoryInfo subfolder in folder.GetDirectories())
      { ClearFolder(subfolder); }
}
 
public static void Main( )
{
   new Test().clearIECache ();
}
0
 
dev_qasourceAuthor Commented:
Hi,

Thanks for the solution. Do you have similar code to maximize the web browser using C#?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.