Empty Recycle Bin using VB.NET

This tutorial will teach you how to create a program that can delete all the files in the Recycle Bin and Empty it using the VB.NET language. Now, let's start this tutorial! 1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application. 2. Next, add only one Button named Button1 and labeled it as "Empty Bin". You must design your interface like this: output 3. Now, let's do the coding. We will first declare functions named SHEmptyRecycleBin and SHUpdateRecycleBinIcon that will access the shell32 library together with its constants.
  1.     Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hWnd As Int32, ByVal pszRootPath As String, ByVal dwFlags As Int32) As Int32
  2.     Private Declare Function SHUpdateRecycleBinIcon Lib "shell32.dll" () As Int32
  3.  
  4.     Private Const SHERB_NOCONFIRMATION = &H1
  5.     Private Const SHERB_NOPROGRESSUI = &H2
  6.     Private Const SHERB_NOSOUND = &H4
Now, we will create a sub procedure named EmptyRecycleBin that will delete all the files in it. It will also have the constants that we have declared above to be put it in the functions. This will be the main code for emptying the recycle bin.
  1.     Private Sub EmptyRecycleBin()
  2.         SHEmptyRecycleBin(Me.Handle.ToInt32, vbNullString, SHERB_NOCONFIRMATION + SHERB_NOSOUND)
  3.         SHUpdateRecycleBinIcon()
  4.     End Sub
Lastly, we will only put our sub procedure to the Button1 of its Clicking Event.
  1.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         EmptyRecycleBin()
  3.     End Sub
Try it and it will delete all files in the recycle bin! For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below. Best Regards, Engr. Lyndon Bermoy IT Instructor/System Developer/Android Developer/Freelance Programmer Mobile: 09488225971 Landline: 826-9296 E-mail:[email protected] Add and Follow me on Facebook: https://www.facebook.com/donzzsky Visit and like my page on Facebook at: https://www.facebook.com/BermzISware

Comments

How to Split Percentage and GB Volume Using This String : "Remaining Volume Allocations for the Current Month2% Remaining from maximum possible Peak Download allocation - 1.0GBPeak Download Volume13% Remaining from Total allocation - 12.6GBTotal VolumePeak Volume Used Total Volume Used ***Bandwidth Management Rule - The Bandwidth will be reduced to 64kbps after reaching either maximum peak download volume or the total volume "

How to Split Percentage and GB Volume Using This String : "Remaining Volume Allocations for the Current Month2% Remaining from maximum possible Peak Download allocation - 1.0GBPeak Download Volume13% Remaining from Total allocation - 12.6GBTotal VolumePeak Volume Used Total Volume Used ***Bandwidth Management Rule - The Bandwidth will be reduced to 64kbps after reaching either maximum peak download volume or the total volume " To Send Source Code : [email protected] Thank You

Add new comment