大家好,请问如何vb。net如何删除下面东西?
大家好,请问如何vb。net如何删除下面东西?
就是删除IE cookie,删除文件,清楚历史记录?
请问怎么操作?是不是使用system.io类删除某个文件夹呢?
三个东西都分别在三个文件夹中吗?
能给出代码就好了。谢谢了。
[解决办法]
比较复杂,我还在看.我试过直接从文件夹中删除文件,不知为什么好像不起作用,楼主试试行不行.
Imports System.IO
Imports System.IO.Path
Public Class Form1
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strCookiesFolder As String = My.Computer.Registry.GetValue( "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders ", "Cookies ", Nothing)
Dim strCacheFolder As String = My.Computer.Registry.GetValue( "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders ", "Cache ", Nothing)
Dim strFiles() As String = Directory.GetFiles(strCookiesFolder)
Dim strFile As String
For Each strFile In strFiles
If Path.GetExtension(strFile) = ".txt " Then
File.Delete(strFile)
End If
Next
strFiles = Directory.GetFiles(strCacheFolder)
For Each strFile In strFiles
If strFile.Contains( "Cookie ") Then
File.Delete(strFile)
End If
Next
MsgBox( "Cookies Deleted ")
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim strCacheFolder As String = My.Computer.Registry.GetValue( "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders ", "Cache ", Nothing)
Dim strFiles() As String = Directory.GetFiles(strCacheFolder)
Dim strFolders() As String = Directory.GetDirectories(strCacheFolder)
Dim strFile As String
Dim strFolder As String
Try
For Each strFile In strFiles
File.Delete(strFile)
Next
For Each strFolder In strFolders
Directory.Delete(strFolder, True)
Next
Catch ex As Exception
Exit Try
End Try
MsgBox( "Cache Deleted ")
End Sub
Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim strHistoryFolder As String = My.Computer.Registry.GetValue( "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders ", "History ", Nothing)
Dim strFolders() As String = Directory.GetDirectories(strHistoryFolder)
Dim strFolder As String
Try
For Each strFolder In strFolders
Directory.Delete(strFolder, True)
Next
Catch ex As Exception
Exit Try
End Try
MsgBox( "History Deleted ")
End Sub
End Class