`
fengzgxing
  • 浏览: 242751 次
  • 性别: Icon_minigender_1
  • 来自: 四川
社区版块
存档分类
最新评论

http://hi.baidu.com/cqzxc/blog/item/5a4db5ca4f95218cc91768de.html

阅读更多
转载于: http://hi.baidu.com/cqzxc/blog/item/5a4db5ca4f95218cc91768de.html

c# 清除IE缓存2009-10-31 22:11#region private void ClearIECache() // 清除IE缓存
        // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// 清除IE缓存
        /// </summary>
        private void ClearIECache()
        {
            Process process = new Process();
            process.StartInfo.FileName = "cmd.exe";
            process.StartInfo.Arguments = "/c " + "del /f /s /q \"%userprofile%\\Local Settings\\Temporary Internet Files\\*.*\"";
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.RedirectStandardInput = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError = true;
            process.StartInfo.CreateNoWindow = true;
            process.Start();
            string result = process.StandardOutput.ReadToEnd();
        }
        // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        #endregion
        #region private void ClearIECookie() // 清除IE Cookie
        // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// 清除IE Cookie
        /// </summary>
        private void ClearIECookie()
        {
            Process process = new Process();
            process.StartInfo.FileName = "cmd.exe";
            process.StartInfo.Arguments = "/c " + "del /f /s /q \"%userprofile%\\Cookies\\*.*\"";
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.RedirectStandardInput = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError = true;
            process.StartInfo.CreateNoWindow = true;
            process.Start();
            string result = process.StandardOutput.ReadToEnd();
        }
        // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        #endregion

        #region private void KillIEWindows() // 关闭IE窗口
        // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// 关闭IE窗口
        /// </summary>
        private void KillIEWindows()
        {
            Process[] process = Process.GetProcesses();
            for (int i = 0; i < process.Length; i++)
            {
                if (process[i].ProcessName.ToLower() == "iexplore")
                {
                    try
                    {
                        process[i].Kill();
                        Thread.Sleep(500);
                    }
                    catch
                    {
                    }
                }
            }
        }
        // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        #endregion

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics