Link to home
Start Free TrialLog in
Avatar of LeighWardle
LeighWardleFlag for Australia

asked on

VB6 Copyfile function gives "Access is Denied" error

Hi Experts,

One of my users has struck a problem with my VB6 application.
This code works fine on dozens of sites.

On his PC:
     App.Path = "C:\Program Files\circly5"
     strDataPath = "C:\Program Files\circly5\data"

The error message is:

Copy failed. Access is denied.
"C:\Program Files\circly5\circ32.pif","C:\Program Files\circly5\data\circ32.pif"

Regards,
Leigh


RetVal = CopyFile(App.Path & "\circ32.pif", strDataPath & "\circ32.pif", False) 'Overwrite if file exists (20061116)
        If RetVal = 0 Then  ' failure
            
            '20051117: added code to output error message corresponding to Err.LastDllError
            Dim strErrorMessage As String
            strErrorMessage = ""
            If Err.LastDllError <> 0 Then
                strErrorMessage = strGetErrorMessage(Err.LastDllError)
            End If
        
            strMessage = "Copy failed. " & strErrorMessage & vbCrLf & chrCommandLineDelimiter & App.Path & "\circ32.pif" & chrCommandLineDelimiter & "," & chrCommandLineDelimiter & strDataPath & "\circ32.pif" & chrCommandLineDelimiter
            MsgBox strMessage, vbInformation
            Logger.Log 1, strMessage
         Else  ' success
            'PrintToDebugFile "Copy succeeded."
        End If

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of nffvrxqgrcfqvvc
nffvrxqgrcfqvvc

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial