Results 1 to 2 of 2

Thread: SHFileOperation problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Philadelphia
    Posts
    123

    SHFileOperation problem

    I'm using SHFileOperation to copy a folder from one location to another. Here is my code:

    VB Code:
    1. Dim SHFileOp As SHFILEOPSTRUCT  
    2. Dim lngSuccess As Long          
    3.    
    4.    
    5.     With SHFileOp
    6.         .hwnd = 0
    7.         .wFunc = FO_COPY
    8.         .pFrom = strSource
    9.         .pTo = strTarget
    10.         .lpszProgressTitle = "Please wait, backing up..."
    11.         .fFlags = FOF_NOERRORUI
    12.     End With
    13.    
    14.     lngSuccess = SHFileOperation(SHFileOp)
    15.              
    16.     If SHFileOp.fAnyOperationsAborted Then
    17.           'Handle abort
    18.     End If
    19.  
    20.     Select Case lngSuccess
    21.            'Handle errors
    22.     End Select

    If all goes well, everything works fine. But I'm having problems with trying to handle the errors it produces. For some reason, I get the same error code (lngSuccess = 117) when I either cancel the file copy or when a file in the directory being copied is currently open. I want to handle these two cases differently, though. I've tried using fAnyOperationsAborted and fAborted but they don't differentiate between the two cases either.

    Any ideas?
    VB6 & VC++6 Pro (SP4), Java (Sun JDK)

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    why not just use normal error handling code?
    VB Code:
    1. Exit Sub
    2.  
    3. SomeError:
    4.  
    5. If err.number=117 then
    6.    msgbox "No way!"
    7. elseif 'blah blah blah
    8. '...
    9. End if
    10.  
    11. End Sub

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