我要清除所有Cookie在我的IE浏览器与下面的代码:错误清除当浏览器cookie C#
public void ClearCookie()
{
string[] Cookies =
System.IO.Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache));
foreach (string currentFile in Cookies)
{
try
{
System.IO.File.Delete(currentFile);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
但是当我运行,一个消息框,与内容appeares:该进程无法访问该文件:C: \ User ... \ Microsoft \ Windows \ Temporary InterNet Files \ counter.dat',因为它正在被另一个进程使用 我应该怎么做才能解决这个问题?
关闭浏览器 –