How to empty a recycle bin

Introduction

Usage:
Dim Action As New ShellActions
Action.EmptyRecycleBin()

Public Class ShellActions

Shared Function _
SHEmptyRecycleBin(ByVal hWnd As Integer, ByVal pszRootPath As String, _
ByVal dwFlags As Integer) As Integer
End Function

Sub New()
EmptyRecycleBin()
End Sub

Sub EmptyRecycleBin(Optional ByVal rootPath As String = "", _
Optional ByVal noConfirmation As Boolean = True, Optional ByVal NoProgress _
As Boolean = True, Optional ByVal NoSound As Boolean = True)

Const SHERB_NOCONFIRMATION = &H1
Const SHERB_NOPROGRESSUI = &H2
Const SHERB_NOSOUND = &H4

If rootPath.Length > 0 AndAlso rootPath.Substring(1, 2) <> ":\" Then
rootPath = rootPath.Substring(0, 1) & ":\"
End If

Dim flags As Integer = (noConfirmation And SHERB_NOCONFIRMATION) Or _
(NoProgress And SHERB_NOPROGRESSUI) Or (NoSound And SHERB_NOSOUND)
SHEmptyRecycleBin(0, rootPath, flags)

End Sub

You might also like...

Comments

Peter Rekdal Sunde

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debugging is anticipated with distaste, performed with reluctance, and bragged about forever.” - Dan Kaminsky