C # Clear cookies,

Source: Internet
Author: User

C # Clear cookies,

  

Different browsers store cookie files in different places

The following is the path for storing cookies in the C # WebBrowser control:

C: \ Users \ {your account name} \ AppData \ Local \ Microsoft \ Windows \ INetCookies

 

  

For information on the cookie file format, see the following code for clearing 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 have been deleted. "); Console. read ();} static void DelCookies (string domain) // domain is the domain of cookies, this method is to clear cookies through the domain Filter {// get the file path in the Directory string [] cookies = Directory. getFi Les (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) // determine whether to Delete the cookies File {file. Delete (File) ;}} catch (Exception ex ){}}}}}

 

Address: http://www.cnblogs.com/iamlucky/p/6010858.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.