Introduction
Here demonstrating, How to delete file to recycle bin through VB.NetBelow 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); } }
Conclusion
Above code snippet displays, Delete file to recycle bin in VB.Net.Suggested Reading
- What is difference between Interface and Abstraction Class ?
- MVC ASP.Net Interview Questions And Answers
- Transpose Datatable C#
- How to Design Entity Relationship Diagram ?
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 https://wikiext.com/zip , and finally I found this program, using which I was able to open my file.
ReplyDelete