Home All Groups Group Topic Archive Search About

Empty Recycle bin - VB.NET code

Author
7 Jul 2006 4:51 PM
vighnesh
Hi All

Can Anybody Please help me in how to Empty a Recycle bin using VB.NET code ?

Regards
Vighneswar

Author
7 Jul 2006 5:47 PM
Jared Parsons [MSFT]
Hello vighnesh,

> Hi All
>
> Can Anybody Please help me in how to Empty a Recycle bin using VB.NET
> code ?

I believe that you need to P/Invoke for this functionality.  Good news is
that there is a sample up on Pinvoke.net to do this very thing.

http://www.pinvoke.net/default.aspx/shell32/SHEmptyRecycleBin.html


--
Jared Parsons [MSFT]
jared***@online.microsoft.com
All opinions are my own. All content is provided "AS IS" with no warranties,
and confers no rights.
Author
7 Jul 2006 10:32 PM
Peter
This is how you do it:

Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias
"SHEmptyRecycleBinA" (ByVal hWnd As Int32, ByVal pszRootPath As String,
ByVal dwFlags As Int32) As Int32
Private Declare Function SHUpdateRecycleBinIcon Lib "shell32.dll" () As
Int32

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

#Region "Empty Recycle Bin (SUB)"

Private Sub EmptyRecycleBin()
  SHEmptyRecycleBin(Me.Handle.ToInt32, vbNullString, SHERB_NOCONFIRMATION +
SHERB_NOSOUND)
  SHUpdateRecycleBinIcon()
End Sub

#End Region

I hope this helps,

Crouchie1998
MCP MCSE
Show quoteHide quote
"vighnesh" <vighn***@nannacomputers.com> wrote in message
news:enD3rWeoGHA.3452@TK2MSFTNGP05.phx.gbl...
> Hi All
>
> Can Anybody Please help me in how to Empty a Recycle bin using VB.NET code
?
>
> Regards
> Vighneswar
>
>