I am using the Scripting.FileSystemObject to copy files in a folder to
multiple folder locations using the .CopyFile methiod (no problem) .. then
attempting to delete the folder at the original location using the
..DeleteFolder method in the same procedure.

The files get copied to the specified location but errors when the
..DeleteFolder is tiggered in the code.
Am am receiving the error:

Run-time error '70'
Permission denied

I can check the folder and all files have been removed but the folder will
not delete ...

Is there any solution to get past this problem ???

R. Hicks



Ken Snell [MVP]

Two sources for that error, to my recollection:

(1) there is a file still in the folder. Delete all files from the folder.

(2) the application that is running the code has its current path
(directory) set to that folder. Change the current directory of the
application that is running the code and then delete the folder.




Thanks Ken ....
I searched my procedure and found where I referenced a value from the
FileSystemObject and assigned it to a string variable in the procedure ...
I only needed to set this variable to an empty string value before the
delete attempt .. and "all work fine" ...

Thanks for the quick response and the solution.
I will not quickly forget this as I have been fighing it all day.

R. Hicks

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

Similar Threads

FileSystemObject 2
FileSystemObject 5
FileSystemObject 2
FileSystemObject 1
FileSystemObject No LongName 1
FileSystemObject drive error 4
FileSystemObject Remane file 7
Question re FileSystemObject 2