How To Clean Recycle Bin Using VB.NET

this is simple snippet , i am using a function to do this work ok now add this functions and a sub included


 Private Declare Function clearRecycleBin Lib "shell32.dll" Alias "clearRecycleBinA" (ByVal hWnd As Int32, ByVal pszRootPath As String, ByVal dwFlags As Int32) As Int32
    Private Declare Function UpdateRecycleBinIcon Lib "shell32.dll" () As Int32

    Private Const SHERB_NOCONFIRMATION = &H1
    Private Const SHERB_NOPROGRESSUI = &H2
    Private Const SHERB_NOSOUND = &H4
    
    Private Sub clearrecycle()
        clearRecycleBin(Me.Handle.ToInt32, vbNullString, SHERB_NOCONFIRMATION + SHERB_NOSOUND)
        UpdateRecycleBinIcon()
    End Sub


now call the functions using this code

   clearrecycle()

you can add the code to any click events such as button1_click event

Post a Comment