Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim result As MsgBoxResult = MsgBox("Deleting these temporary files may affect your use of Internet Explorer, would you still like to continue?", MsgBoxStyle.YesNo, "Warning:") If (result = MsgBoxResult.Yes) Then 'Continue with deletion End If End Sub
Dim username As String = Environ("Username") Dim path As String = "C:\Users\" + username + "\AppData\Local\Microsoft\Windows\INetCache\IE"
Dim preClean As Integer = 0 preClean += My.Computer.FileSystem.GetFiles(path).Count() preClean += My.Computer.FileSystem.GetDirectories(path).Count() MsgBox("Total files and directories pre-cleaning: " + preClean.ToString())
For Each f As String In My.Computer.FileSystem.GetFiles(path) My.Computer.FileSystem.DeleteFile(f) Next For Each f As String In My.Computer.FileSystem.GetDirectories(path) My.Computer.FileSystem.DeleteDirectory(f, FileIO.DeleteDirectoryOption.DeleteAllContents) Next
Dim afterClean As Integer = 0 afterClean += My.Computer.FileSystem.GetFiles(path).Count() afterClean += My.Computer.FileSystem.GetDirectories(path).Count() MsgBox("Total files and directories pre-cleaning: " + preClean.ToString() + vbNewLine + "Total files and directories after-cleaning: " + afterClean.ToString() + vbNewLine + "Total deleted: " + (preClean - afterClean).ToString())