Delete file to recycle bin in VB.Net

Delete file to recycle bin in, Delete file to recycle bin in VB.Net, Delete file in C#


Here demonstrating, How to delete file to recycle bin through VB.Net
Below is code stuff to delete the file to recycle bin. Sometimes, we need send deleted drives files to recycle bin not to delete permanently because we can recover deleted file if required it later.

VB.Net Code

 Public Shared Sub Sample()
 Dim filepath As String = "c:\checkforbin.txt"
 Dim fi As FileInfo = New FileInfo("C:\checkforbin.txt")

  If fi.Exists Then My.Computer.FileSystem.DeleteFile(filepath, FileIO.UIOption.OnlyErrorDialogs,  FileIO.RecycleOption.SendToRecycleBin,FileIO.UICancelOption.DoNothing)
        End If
  End Sub

C# Code

public static void Sample() 
 string filepath = "c:\\checkforbin.txt";
 FileInfo fi = new FileInfo("C:\\checkforbin.txt");
    if (fi.Exists) 
  My.Computer.FileSystem.DeleteFile(filepath, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin, FileIO.UICancelOption.DoNothing);


Above code snippet displays, Delete file to recycle bin in VB.Net.

Suggested Reading


Anjan kant

Outstanding journey in Microsoft Technologies (ASP.Net, C#, SQL Programming, WPF, Silverlight, WCF etc.), client side technologies AngularJS, KnockoutJS, Javascript, Ajax Calls, Json and Hybrid apps etc. I love to devote free time in writing, blogging, social networking and adventurous life

Post A Comment:


  1. Thanks for your post, sometimes it's very necessary to restore the deleted file! I managed to create a BIN file today, but I could not open it. The whole day I was looking for how to open .bin file , and finally I found this program, using which I was able to open my file.