Strange Problem with Scripting.FileSystemObject

Joined
Jul 6, 2010
Messages
5
Reaction score
0
SOLVED: Strange Problem with Scripting.FileSystemObject

Hello,

I have some simple code that used to work in Access 2000 and now gives me a strange problem in Access 2003.

I can delete a file in, and copy a file into, my c:\ root directory, but when I try it in a sub-folder under C:\Program Files, I get Run-time error 70 (permission denied).

My client is getting the same problem on his network as well.

Here is the code:

Set fs = CreateObject("Scripting.FileSystemObject")

'This code No Longer Works:
fs.DeleteFile ("c:\Program Files\ABC_Systems\is-data.mdb")
fs.CopyFile "F:\ABC_Systems\is-data.mdb", "c:\Program Files\ABC_Systems\", overwrite

'This code Works Fine:
fs.DeleteFile ("c:\is-data.mdb")
fs.CopyFile "F:\ABC_Systems\is-data.mdb", "c:\", overwrite

Thank you in advance for any help.

Peter
 
Last edited:
Upon further thought and research, this must be due to a lock still existing on the file I'm trying to copy.
I'm trying to copy the file from the F: drive to the C: drive as the user is about to disconnect from the network and needs to take copies of certain files with him.
This is happening just as he's closing the main menu form and is about to encounter "Exit" in the next line of code.
How do I release the lock programmatically to allow this file to be copied?

Thanks,
Peter
 
Solved by original poster.

I had mistakenly linked a table from the C: drive instead of the F: drive so there was a lock (found the LDB file) on the C: file I was trying to delete and refresh.
 
Back
Top