国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C# 清除cookies的代碼

2019-10-29 21:19:53
字體:
供稿:網(wǎng)友

不同的瀏覽器會把cookie文件保存在不同的地方

  以下是C# WebBrowser控件cookies的存放路徑

  C:/Users/{你的帳號名}/AppData/Local/Microsoft/Windows/INetCookies

C#,清除cookies

  cookies文件格式請查看相關(guān)資料

下面是清除cookies的代碼:

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.IO;namespace DelCookies{class Program{static void Main(string[] args){DelCookies("360.cn/");Console.WriteLine("cookies已刪除.");Console.Read();}static void DelCookies(string domain) //domain是cookies所屬域,此方法是通過所屬域過濾清除cookies{//獲取目錄中文件路徑string[] cookies = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Cookies));foreach (string file in cookies){try{StreamReader sr = new StreamReader(file);string txt = sr.ReadToEnd();sr.Close();if (txt.IndexOf(domain) != -1) //判斷是否刪除的cookies文件{File.Delete(file);}}catch (Exception ex){}} }}}

關(guān)于C# 清除cookies的代碼就給大家寫這么多,希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時回復(fù)大家的!


注:相關(guān)教程知識閱讀請移步到c#教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 黔西县| 大洼县| 米泉市| 忻州市| 金川县| 如皋市| 定安县| 磴口县| 宁陵县| 临沂市| 贡嘎县| 中宁县| 桂阳县| 长兴县| 乌拉特中旗| 永善县| 厦门市| 西青区| 噶尔县| 抚远县| 邻水| 高陵县| 仙游县| 洪湖市| 阿巴嘎旗| 天峨县| 威远县| 于田县| 蓝田县| 清远市| 师宗县| 峨眉山市| 达孜县| 威远县| 宁安市| 南丹县| 隆回县| 三穗县| 耿马| 西和县| 清丰县|