Copy file code, copys all files, some of the time? error

Directlinq

Registered User.
Local time
Today, 11:01
Joined
Sep 13, 2009
Messages
67
Hi
Im having an issue with the following code which copys all .MPG files from a dvd disc to a folder on the pc, while copying a progress bar shows. What is happening is sometimes not all files from the discs are being copyed to the computer. But using the same disc it alows me to copy them across manually. So the discs do not have data errors. Is there a problem with this code. I put the "On Error Resume Next" so if data errors did occur it could skip the file and go to the next, but i have no data errors???
Is there a way around this or has anybody got any clues for me to help me solve this problem?

Here is the stripped down code im using

Code:
Private Declare Function SHFileOperation Lib "shell32.dll" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Type SHFILEOPSTRUCT
        hwnd As Long
        wFunc As Long
        pFrom As String
        pTo As String
        fFlags As Integer
        fAnyOperationsAborted As Long
        hNameMappings As Long
        lpszProgressTitle As String
End Type
Private Const FOF_CREATEPROGRESSDLG = &H0
Private Const FO_COPY = 2
Private Const FoF_SILENT = &H4

Private Sub Command1_Click()
Dim SH As SHFILEOPSTRUCT
On Error Resume Next

    With SH
        .fFlags = FoF_SILENT 'flag for progressbar
        .wFunc = FO_COPY
        .pFrom = "D:\*.MPG"
        .pTo = "F:\MediaLib\Video"
    End With
    
   Call SHFileOperation(SH)
End If
Exit Sub

Thanks in advance
 
i am not familiar with the library you are using. The only thing I can think of, is that maybe .pto needs to be

.pTo = "F:\MediaLib\Video\*.*"


actually, looking at the code again - this isn't quite right. you have an end if, with no if, in the main function.

in any event, i can't see that the on error will help. i doubt if the function will return an handleable error code, even if it fails - it will probably just return a non normal value for the function result. what you probably need is this

dim result as long
result = shfileoperation(SH)


and then see what result value you get. 0 is probably a normal end.
 

Users who are viewing this thread

Back
Top Bottom