VB.NET Clean my chrome source code



------------------------------------------------------------------------------------------
Imports System.IO
Public Class frm_main
    Private Sub btn_ok_Click(sender As Object, e As EventArgs) Handles btn_ok.Click

        Try

            'Plug-in name xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
            Delete("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")

            MsgBox("Finished. :)", MsgBoxStyle.Information)

        Catch ex As Exception
            MsgBox("Error !", MsgBoxStyle.Critical)
        End Try

    End Sub

    Private Sub btn_cleanfile_Click(sender As Object, e As EventArgs) Handles btn_cleanfile.Click
        Dim MyDirectories As DirectoryInfo = New DirectoryInfo("C:\Users\")
        Dim User_path, AppData_path, X64p_path, X64chrome_path, X86chrome_path As String
        User_path = "C:\Users\"
        AppData_path = "\AppData\Local\Google"
        X64p_path = "C:\Program Files (x86)"
        X64chrome_path = "C:\Program Files (x86)\Google"
        X86chrome_path = "C:\Program Files\Google"

        Try
            For Each MyDirectories_name As DirectoryInfo In MyDirectories.GetDirectories

                If My.Computer.FileSystem.DirectoryExists(User_path & MyDirectories_name.ToString & AppData_path) = True Then
                    My.Computer.FileSystem.DeleteDirectory(User_path & MyDirectories_name.ToString & AppData_path, FileIO.DeleteDirectoryOption.DeleteAllContents)
                End If

                If My.Computer.FileSystem.DirectoryExists(X64p_path) = True Then
                    My.Computer.FileSystem.DeleteDirectory(X64chrome_path, FileIO.DeleteDirectoryOption.DeleteAllContents)
                Else
                    My.Computer.FileSystem.DeleteDirectory(X86chrome_path, FileIO.DeleteDirectoryOption.DeleteAllContents)
                End If

            Next

            MsgBox("Finished. :)", MsgBoxStyle.Information)

        Catch ex As Exception
            MsgBox("Error !", MsgBoxStyle.Critical)
        End Try

    End Sub

    Private Sub cb_warning_CheckedChanged(sender As Object, e As EventArgs) Handles cb_warning.CheckedChanged
        If cb_warning.Checked = True Then
            btn_cleanfile.Enabled = True
        Else
            btn_cleanfile.Enabled = False
        End If
    End Sub
    Private Sub Delete(ByVal Dir_Name As String)
        Dim MyDirectories As DirectoryInfo = New DirectoryInfo("C:\Users\")
        Dim User_path, Defaul_path, Profile1_path As String
        User_path = "C:\Users\"
        Defaul_path = "\AppData\Local\Google\Chrome\User Data\Default\Extensions\"
        Profile1_path = "\AppData\Local\Google\Chrome\User Data\Profile 1\Extensions\"

        For Each MyDirectories_name As DirectoryInfo In MyDirectories.GetDirectories

            If My.Computer.FileSystem.DirectoryExists(User_path & MyDirectories_name.ToString & Defaul_path & Dir_Name) = True Then
                My.Computer.FileSystem.DeleteDirectory(User_path & MyDirectories_name.ToString & Defaul_path & Dir_Name, FileIO.DeleteDirectoryOption.DeleteAllContents)
            End If

            If My.Computer.FileSystem.DirectoryExists(User_path & MyDirectories_name.ToString & Profile1_path & Dir_Name) = True Then
                My.Computer.FileSystem.DeleteDirectory(User_path & MyDirectories_name.ToString & Profile1_path & Dir_Name, FileIO.DeleteDirectoryOption.DeleteAllContents)
            End If

        Next

    End Sub
End Class

BY TN-Man :)

留言