Library code snippets
How to empty a recycle bin
By Peter Rekdal Sunde, published on 06 May 2006
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
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
Related articles
Related discussion
-
MSSQL Query in VB.Net Fails
by 7upsk (1 replies)
-
bar graphs in visual basic.net
by bhabybash (1 replies)
-
How to write the category attribut in a class dynamically
by converter2009 (1 replies)
-
VB.NET: Hide and show table using radio buttons
by converter2009 (1 replies)
-
VB.Net Button Problem
by pysdex (0 replies)
Related podcasts
-
xpert to Expert: Inside Concurrent Basic (CB)
"Concurrent Basic extends Visual Basic with stylish asynchronous concurrency constructs derived from the join calculus. Our design advances earlier MSRC work on Polyphonic C#, Comega and the Joins Library. Unlike its C# based predecessors, CB adopts a simple event-like syntax familiar to VB progr...
Comments
Leave a comment
Sign in or Join us (it's free).