CopyFile method of FileSystemObject produces runtime error 70

P

phil

Hi,

I have a piece of code that was working before, but now
produces a runtime error 70, permission denied. Here's
the code, where beString is the linked database (such
as "C:\database.mdb") and versionLoc is the name of the
folder it will be copied to (such as "tempfolder")


Public Function CopyBackend(beString As String, versionLoc
As String)
Dim fs As Object

Set fs = CreateObject("Scripting.FileSystemObject")

'Copy the backed database to C:\ drive
If fs.FolderExists(versionLoc) = True Then
fs.DeleteFolder versionLoc, True
End If
fs.CreateFolder versionLoc
fs.CopyFile beString, versionLoc

Set fs = Nothing

End Function

Does anyone have any insight into why this error is
occuring?

Thanks,
Phil
 
P

phil

I should clarify by adding that the variable versionLoc is
a string that includes the path, such as "C:\tempfolder"
 
K

Ken Snell

Either the file that you're copying is open when the code is running, or the
file that you're copying on top of is open when the code runs. Or you don't
have a \ character at the end of the versionLoc string value.
 
P

phil

Thanks Ken - it was the latter. Just put this code in
right before the CopyFile:

versionLoc = versionLoc + "\"

Thanks a bunch!
 
K

Ken Snell

You're welcome.

phil said:
Thanks Ken - it was the latter. Just put this code in
right before the CopyFile:

versionLoc = versionLoc + "\"

Thanks a bunch!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top