码迷,mamicode.com
首页 > Web开发 > 详细

清除webBrowser 缓存和Cookie的解决方案

时间:2014-06-08 20:20:09      阅读:315      评论:0      收藏:0      [点我收藏+]

标签:c   class   blog   code   java   a   

通过测试webBrowser与IE缓存和Cookie都存放在Local Settings\Temporary Internet Files,我们可以直接调用IE API进行清除

解决方案1:

bubuko.com,布布扣
bubuko.com,布布扣
public enum ShowCommands : int

{

SW_HIDE = 0,

SW_SHOWNORMAL = 1,

SW_NORMAL = 1,

SW_SHOWMINIMIZED = 2,

SW_SHOWMAXIMIZED = 3,

SW_MAXIMIZE = 3,

SW_SHOWNOACTIVATE = 4,

SW_SHOW = 5,

SW_MINIMIZE = 6,

SW_SHOWMINNOACTIVE = 7,

SW_SHOWNA = 8,

SW_RESTORE = 9,

SW_SHOWDEFAULT = 10,

SW_FORCEMINIMIZE = 11,

SW_MAX = 11

}
bubuko.com,布布扣
bubuko.com,布布扣

 

bubuko.com,布布扣
[DllImport("shell32.dll")]

static extern IntPtr ShellExecute( IntPtr hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, ShowCommands nShowCmd);
bubuko.com,布布扣

 

bubuko.com,布布扣
//清除IE临时文件

                ShellExecute(IntPtr.Zero, "open", "rundll32.exe", " InetCpl.cpl,ClearMyTracksByProcess 255", "", ShowCommands.SW_HIDE);
bubuko.com,布布扣

 

 

其中ClearMyTracksByProcess 可进行选择设置 :

 

Temporary Internet Files  (Internet临时文件)

 

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8

 

Cookies

 

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2

 

History (历史记录)

 

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1

 

 

 Form. Data (表单数据)

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16

 

 

 Passwords (密码)

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32

 

 

 Delete All  (全部删除)

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255

 

解决方案2:快速清除webBrowser Cookie

 

bubuko.com,布布扣
wb.Document.Cookie.Remove(0, (wb.Document.Cookie.Count - 1))
bubuko.com,布布扣

 

 

 

清除webBrowser 缓存和Cookie的解决方案,布布扣,bubuko.com

清除webBrowser 缓存和Cookie的解决方案

标签:c   class   blog   code   java   a   

原文地址:http://www.cnblogs.com/mvc2014/p/3775964.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!