|
-
Feb 13th, 2004, 07:06 AM
#1
Thread Starter
Lively Member
Delete to Recycle Bin
am i missing something, is there an argument after file.delete that would send it to the recycle bin, or do you still have to do the api call and actually move file to recycle bin like vb6, i cant seem to find any arguements for file.delete i know directory.delete has
VB Code:
directory.delete (sDir, true) ' which deletes recursively by force
any1 know this off hand?
-
Feb 13th, 2004, 07:17 AM
#2
Thread Starter
Lively Member
heres the api call is there a better way???
VB Code:
'''''''''''''module
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
'''''''''''form
Recycle("C:\test.pdf")
-
Feb 13th, 2004, 11:50 AM
#3
Addicted Member
Hi,
I have no answer for you.
I only want to be Notification on this subject.
Have a nice day
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|