Results 1 to 3 of 3

Thread: Delete to Recycle Bin

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2003
    Location
    US
    Posts
    68

    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:
    1. directory.delete (sDir, true) ' which deletes recursively by force

    any1 know this off hand?

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Mar 2003
    Location
    US
    Posts
    68
    heres the api call is there a better way???

    VB Code:
    1. '''''''''''''module
    2. Option Strict Off
    3. Option Explicit On
    4. Imports System.IO
    5. Module Module1
    6.    
    7.   Private Structure SHFILEOPSTRUCT
    8.     Dim hwnd As Integer
    9.     Dim wFunc As Integer
    10.     Dim pFrom As String
    11.     Dim pTo As String
    12.     Dim fFlags As Short
    13.     Dim fAnyOperationsAborted As Boolean
    14.     Dim hNameMappings As Integer
    15.     Dim lpszProgressTitle As String
    16.   End Structure
    17.    
    18.   Private Const FO_DELETE As Short = &H3s
    19.   Private Const FOF_ALLOWUNDO As Short = &H40s
    20.   Private Const FOF_NOCONFIRMATION As Short = &H10s
    21.    
    22.   Private Declare Function SHFileOperation Lib "shell32.dll" Alias _
    23.     "SHFileOperationA" (ByRef lpFileOp As SHFILEOPSTRUCT) As Integer
    24.    
    25.   Public Function Recycle(ByRef sPath As String) As Integer
    26.       Dim FileOp As SHFILEOPSTRUCT
    27.       If Not File.Exists(sPath) Then
    28.         MsgBox("Could not find " & sPath & "." & vbCrLf _
    29.         & "Please verify the path.")
    30.         Recycle = -1
    31.         Exit Function
    32.       End If
    33.       With FileOp
    34.         .wFunc = FO_DELETE
    35.         .pFrom = sPath & vbNullChar
    36.         .pTo = vbNullChar
    37.         .fFlags = FOF_NOCONFIRMATION Or FOF_ALLOWUNDO
    38.         .lpszProgressTitle = "Sending " & sPath & " to the Recycle Bin"
    39.       End With
    40.       Try
    41.         SHFileOperation(FileOp)
    42.       Catch ex As Exception
    43.         MsgBox(ex.Message)
    44.       End Try
    45.       Recycle = 0
    46.   End Function
    47. End Module
    48.  
    49.  
    50. '''''''''''form
    51. Recycle("C:\test.pdf")

  3. #3
    Addicted Member
    Join Date
    Aug 2002
    Posts
    224
    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
  •  



Click Here to Expand Forum to Full Width