LeighWardle
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:\Progra m Files\circly5\data\circ32. pif"
Regards,
Leigh
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",
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.