Copy a protected file else where - FileCopy Statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I tried to use the FileCopy Statement to copy a file located in a read only
folder to an other folder that has no restriction. But it did not work and I
get an error message . Is there a way to do it in VB?
(It is for a MS Access 2000 Application)

Doing it manualy: Copy of files from the read only folder and paste to a
folder that has no restriction works in Windows Explorer. But I'm looking to
do it in VB from a command button...

Thanks,
 
Perhaps file is opened, then try to use API function:

Private Declare Function apiCopyFile Lib "kernel32" _
Alias "CopyFileA" _
(ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String, _
ByVal bFailIfExists As Long) _
As Long

call apiCopyFile(strSource, strTarget, boolFailIfExists)
 
It works!

Thanks,

Michael


Alex Dybenko said:
Perhaps file is opened, then try to use API function:

Private Declare Function apiCopyFile Lib "kernel32" _
Alias "CopyFileA" _
(ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String, _
ByVal bFailIfExists As Long) _
As Long

call apiCopyFile(strSource, strTarget, boolFailIfExists)
 
Back
Top