如何从Temporary Internet files文件夹中删除我的cookie文件? [英] How to delete my cookie file from Temporary Internet files folder ?

查看:114
本文介绍了如何从Temporary Internet files文件夹中删除我的cookie文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我做了一个代码来从Temporary Internet文件中删除我的cookie文件,但它无法正常工作并退出foreach循环。代码是

Hello,
I did a code to delete my cookie file from the Temporary Internet files but its not working and going out of the foreach loop. The code is

var path = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
foreach (FileInfo fileInfo in directoryInfo.GetFiles("Cookie:abc.xyz@dev.livestuff.com/.txt"))
{
   fileInfo.Delete();
}



现在我要删除我的cookie文件了吗?


Now what I have to do to delete my cookie file ?

推荐答案

你不能。



有各种各样的原因,从以下开始:

1)Cookie存储在客户端,而不是服务器上,所以除了通过Cookies类之外你无法使用C#代码访问它们。

2)所有浏览器都不会将它们存储在同一个地方:例如Chrome使用SQLite数据库代替单个文件,并在运行时保持数据库打开和锁定,因此您甚至无法在不关闭浏览器的情况下直接访问它。



使用正常 删除cookie的界面:

You can't.

There are all sorts of reasons, starting with:
1) Cookies are stored on the client, not the server, so you can't access them with C# code anyway except via the Cookies class.
2) They aren't stored in the same place by all browsers anyway: Chrome for example uses an SQLite database instead of individual files, and holds the DB open and locked while it is running, so you can't even access it directly without closing the browser.

Use the "normal" interface to remove cookies:
if (Request.Cookies["UserId"] != null)
{
    Response.Cookies["UserId"].Expires = DateTime.Now.AddDays(-1);
}

将指示浏览器将其删除。浏览器实际上做了什么,但是没有定义......

Will direct the browser to remove it. What the browser actually does as a result though, it not defined...


试试这些:



C# - 如何删除临时互联网文件 [ ^ ]



用C#清除临时Internet文件 [ ^ ]



c#nse File.Delete无法删除临时互联网文件文件 [ ^ ]



:):):)
Try these :

C# - How to Delete temporary internet files[^]

Clearing Temporary Internet Files in C#[^]

c# nse File.Delete cannot delete "Temporary Internet Files" files[^]

:):):)


这篇关于如何从Temporary Internet files文件夹中删除我的cookie文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆