• We just launched and are currently in beta. Join us as we build and grow the community.

Empty Recycle Bin using VB.NET

vinonaweil

Revenue Diversification Expert
V Rep
0
0
0
Rep
0
V Vouches
0
0
0
Vouches
0
Posts
128
Likes
100
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
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:

recyclebin.png


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. Private

    Const

    SHERB_NOCONFIRMATION =

    &

    H1
  4. Private

    Const

    SHERB_NOPROGRESSUI =

    &

    H2
  5. 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


Download
You must upgrade your account or reply in the thread to view hidden text.
 

452,292

323,341

323,350

Top