最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#控制IE進(jìn)程關(guān)閉和緩存清理的實(shí)現(xiàn)代碼

 更新時(shí)間:2014年04月15日 10:25:56   作者:  
這篇文章主要介紹了C#控制IE進(jìn)程關(guān)閉和緩存清理的實(shí)現(xiàn)代碼,需要的朋友可以參考下
復(fù)制代碼 代碼如下:

class IEUtil {
    public static void openIE(string url) {
        try {
            //System.Diagnostics.Process.Start(url);
            System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo.FileName = "iexplore.exe";
            p.StartInfo.Arguments = url;
            p.Start();
        } catch(Exception ex) {
            Log.logger("openIE" + url + "----------" + ex.Message);
        }
    }
    public static void closeAllIEProcess() {
        string defaultBrowserName = GetDefaultBrowerName();
        System.Diagnostics.Process[] procs = System.Diagnostics.Process.GetProcessesByName("IEXPLORE");
        foreach(System.Diagnostics.Process proc in procs) {
            proc.Kill();
        }
    }
    public static void CleanCookie() {
        try {
            string[] theFiles = System.IO.Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Cookies), "*", System.IO.SearchOption.AllDirectories);
            foreach(string s in theFiles) FileDelete(s);
        } catch(Exception e) {
            Log.logger("Delete cookie error" + e.Message);
        }
    }
    static bool FileDelete(string path) {
        //first set the File's ReadOnly to 0
        //if EXP, restore its Attributes
        System.IO.FileInfo file = new System.IO.FileInfo(path);
        System.IO.FileAttributes att = 0;
        bool attModified = false;
        try {
            //### ATT_GETnSET
            att = file.Attributes;
            file.Attributes &= (~System.IO.FileAttributes.ReadOnly);
            attModified = true;
            file.Delete();
        } catch(Exception e) {
            if (attModified) file.Attributes = att;
            return false;
        }
        return true;
    }
    public static string GetDefaultBrowerName() {
        string mainKey = @"http\shell\open\command";
        string nameKey = @"http\shell\open\ddeexec\Application";
        string strRet = string.Empty;
        try {
            RegistryKey regKey = Registry.ClassesRoot.OpenSubKey(nameKey);
            strRet = regKey.GetValue("").ToString();
        } catch {
            strRet = "";
        }
        return strRet;
    }
    /// <summary>
    /// 清除文件夾
    /// </summary>
    /// <param name="path">文件夾路徑</param>
    static void FolderClear(string path) {
        System.IO.DirectoryInfo diPath = new System.IO.DirectoryInfo(path);
        if (diPath.Exists) {
            foreach(System.IO.FileInfo fiCurrFile in diPath.GetFiles()) {
                FileDelete(fiCurrFile.FullName);
            }
            foreach(System.IO.DirectoryInfo diSubFolder in diPath.GetDirectories()) {
                FolderClear(diSubFolder.FullName);
                // Call recursively for all subfolders
            }
        }
    }
    /// <summary>
    /// 執(zhí)行命令行
    /// </summary>
    /// <param name="cmd"></param>
    static void RunCmd(string cmd) {
        ProcessStartInfo p = new ProcessStartInfo();
        p.FileName = "cmd.exe";
        p.Arguments = "/c " + cmd;
        p.WindowStyle = ProcessWindowStyle.Hidden; // Use a hidden window
        Process.Start(p);
    }
    /// <summary>
    /// 刪除臨時(shí)文件
    /// </summary>
    public static void CleanTempFiles() {
        FolderClear(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache));
        RunCmd("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8");
    }
}

相關(guān)文章

  • C# 寫入XML文檔三種方法詳細(xì)介紹

    C# 寫入XML文檔三種方法詳細(xì)介紹

    如何使用LINQ to XML對(duì)XML進(jìn)行操作,我們分別用這三個(gè)類將同樣的xml內(nèi)容寫入文檔,需要了解的朋友可以參考下
    2012-12-12
  • C#調(diào)用RabbitMQ實(shí)現(xiàn)消息隊(duì)列的示例代碼

    C#調(diào)用RabbitMQ實(shí)現(xiàn)消息隊(duì)列的示例代碼

    這篇文章主要介紹了C#調(diào)用RabbitMQ實(shí)現(xiàn)消息隊(duì)列的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-12-12
  • 淺析wpf中datagrid顯示列的問(wèn)題

    淺析wpf中datagrid顯示列的問(wèn)題

    這篇文章主要為大家詳細(xì)介紹了wpf中datagrid顯示列問(wèn)題的相關(guān)知識(shí),文中的示例代碼講解詳細(xì),具有一定的借鑒價(jià)值,有需要的小伙伴可以學(xué)習(xí)一下
    2024-04-04
  • C#中winform窗體實(shí)現(xiàn)注冊(cè)/登錄功能實(shí)例(DBHelper類)

    C#中winform窗體實(shí)現(xiàn)注冊(cè)/登錄功能實(shí)例(DBHelper類)

    在編寫項(xiàng)目時(shí),編寫了一部分關(guān)于登錄頁(yè)面的一些代碼,下面這篇文章主要給大家介紹了關(guān)于C#中winform窗體實(shí)現(xiàn)注冊(cè)/登錄功能(DBHelper類)的相關(guān)資料,文中通過(guò)圖文介紹的非常詳細(xì),需要的朋友可以參考下
    2023-06-06
  • C#使用windows服務(wù)開(kāi)啟應(yīng)用程序的方法

    C#使用windows服務(wù)開(kāi)啟應(yīng)用程序的方法

    這篇文章主要介紹了C#使用windows服務(wù)開(kāi)啟應(yīng)用程序的方法,實(shí)例分析了C#操作windows服務(wù)開(kāi)啟應(yīng)用程序所遇到的問(wèn)題及相關(guān)解決技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-09-09
  • C#同步網(wǎng)絡(luò)時(shí)間的方法實(shí)例詳解

    C#同步網(wǎng)絡(luò)時(shí)間的方法實(shí)例詳解

    這篇文章主要介紹了C#同步網(wǎng)絡(luò)時(shí)間的方法,以實(shí)例形式較為詳細(xì)的分析了C#獲取網(wǎng)絡(luò)時(shí)間與同步本機(jī)系統(tǒng)時(shí)間的相關(guān)技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    2015-05-05
  • c# 曲線圖生成代碼

    c# 曲線圖生成代碼

    c# 曲線圖生成代碼,需要的朋友可以參考下。
    2011-07-07
  • C#編程總結(jié)(六)詳解異步編程

    C#編程總結(jié)(六)詳解異步編程

    本篇文章主要介紹了C#異步編程,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧。
    2016-12-12
  • C#實(shí)現(xiàn)綁定Combobox的方法

    C#實(shí)現(xiàn)綁定Combobox的方法

    這篇文章主要介紹了C#實(shí)現(xiàn)綁定Combobox的方法,涉及Combobox參數(shù)設(shè)置的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-08-08
  • C#使用IronPython調(diào)用Python

    C#使用IronPython調(diào)用Python

    這篇文章主要給大家介紹了關(guān)于C#使用IronPython調(diào)用Python的相關(guān)資料, c#利用IronPython調(diào)用python的過(guò)程中總會(huì)遇到種種問(wèn)題,這里給大家總結(jié)下,需要的朋友可以參考下
    2023-07-07

最新評(píng)論

罗江县| 邮箱| 澄江县| 大姚县| 黄梅县| 保德县| 恭城| 沂水县| 杭州市| 中方县| 济阳县| 卢氏县| 蓬溪县| 湘阴县| 万安县| 涿鹿县| 大竹县| 绥德县| 徐州市| 湾仔区| 高尔夫| 徐水县| 景谷| 漳州市| 馆陶县| 六安市| 桃源县| 邻水| 军事| 洪洞县| 明溪县| 东阿县| 东平县| 汶川县| 炉霍县| 阜宁县| 马公市| 三原县| 青岛市| 景洪市| 锦屏县|