我要清除所有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',因爲它正在被另一個進程使用 我應該怎麼做才能解決這個問題?
關閉瀏覽器 –