Library code snippets
Send File to Recycle Bin in VB .NET
By Walter Steed, published on 07 Feb 2004
This is the VB.NET version of "Send file to recycle bin"
Option Strict Off
Option Explicit On
Imports System.IO
Module Module1
Private Structure SHFILEOPSTRUCT
Dim hwnd As Integer
Dim wFunc As Integer
Dim pFrom As String
Dim pTo As String
Dim fFlags As Short
Dim fAnyOperationsAborted As Boolean
Dim hNameMappings As Integer
Dim lpszProgressTitle As String
End Structure
Private Const FO_DELETE As Short = &H3s
Private Const FOF_ALLOWUNDO As Short = &H40s
Private Const FOF_NOCONFIRMATION As Short = &H10s
Private Declare Function SHFileOperation Lib "shell32.dll" Alias _
"SHFileOperationA" (ByRef lpFileOp As SHFILEOPSTRUCT) As Integer
Public Function Recycle(ByRef sPath As String) As Integer
Dim FileOp As SHFILEOPSTRUCT
If Not File.Exists(sPath) Then
MsgBox("Could not find " & sPath & "." & vbCrLf _
& "Please verify the path.")
Recycle = -1
Exit Function
End If
With FileOp
.wFunc = FO_DELETE
.pFrom = sPath & vbNullChar
.pTo = vbNullChar
.fFlags = FOF_NOCONFIRMATION Or FOF_ALLOWUNDO
.lpszProgressTitle = "Sending " & sPath & " to the Recycle Bin"
End With
Try
SHFileOperation(FileOp)
Catch ex As Exception
MsgBox(ex.Message)
End Try
Recycle = 0
End Function
End Module
Related articles
Related discussion
-
How to write a query set to excel using vb.net
by BarbaMariolino (1 replies)
-
Very Urgent regarding deleting the images from a folder
by rameshbandi (2 replies)
-
Block Accessing MSSQL 2000
by militia (0 replies)
-
.NET Developer in Ghana Required....
by sysview (0 replies)
-
Sending SMS to mobile using secure gateway from VB.net 2008 c#
by pratikasthana17 (0 replies)
Related podcasts
-
xpert to Expert: Inside Concurrent Basic (CB)
"Concurrent Basic extends Visual Basic with stylish asynchronous concurrency constructs derived from the join calculus. Our design advances earlier MSRC work on Polyphonic C#, Comega and the Joins Library. Unlike its C# based predecessors, CB adopts a simple event-like syntax familiar to VB progr...
can this code be used to send entire folders to the recycle bin
!--removed tag-->.NET 2.0
My
.Computer.FileSystem.DeleteFile("Path", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin)hai i am working in a vb.net project. can i able to select one or more picture boxes simultanously at run time. Pls help with a revelent code
Thank You
Soumya
This thread is for discussions of Send File to Recycle Bin in VB .NET.