Different browsers store cookie files in different places
The following is the storage path for C # WebBrowser control cookies
c:\users\{your account name}\appdata\local\microsoft\windows\inetcookies.
Cookies file format Please check the relevant information
Here is the code to clear 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 removed.");
Console.read ();
}
static void Delcookies (string domain)//domain is the domain where the cookies belong, this method is to remove cookies by filtering the owning domain
{
//Get file path string in directory
[] 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)//judge whether to delete the cookies file
{
file.delete (file)
;
}
catch (Exception ex)
{
}
}
}}
About C # to remove cookies code for everyone to write so much, I hope to help you, if you have any questions welcome to my message, small series will promptly reply to everyone!