Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file system object copy folder

Status
Not open for further replies.

jadams0173

Technical User
Feb 18, 2005
1,210
I'm copying a folder from one drive to another for backup purposes. In the folder that I am coping are other folders and files.

There is one file in one of the subfolders that a machine has open and is writing data to that causes the "Permission Denied" error. I don't really care whether I copy this file or not, I just don't want the error message. (It won't copy from windows explorer either xp-sp2 or 2000)

Any one have any suggestions on how to get around this? Would CopyFile work? I was hoping not to have to open each subfolder and use filecopy but if that's what it takes.

Code:
'this will copy the entire folder and all subfolders to the master directory
fso.CopyFolder fld.Path & "\" & Subfld.Name, BackupMaster & "\" & NDFRTF & "\" & Subfld.Name

I tried to have patience but it took to long! :) -DW
 
A quick test showed the fso.FileCopy returns the same Permission Denied error. Is there anything else that may copy this file or just bypass this file?

I tried to have patience but it took to long! :) -DW
 
Trap the error number with On Error and Resume Next if err.num = your error.

Did you hear about the Buddhist who refused Novocain during a root
canal? He wanted to transcend dental medication.
 
The only possible way is that you write a routine in code which will scan through the source folder tree and recursively reproduce the same folder tree at destination copying all files individually.

When you copy all files individually, you can ignore such errors and skip problematic files/folders without aborting the whole operation.

Basically you have to write your own customized implementation of CopyFolder function, ignoring the errors that occur during operation which is not possible with FSO or even with Windows' SHFileOperation API function.
 
Hypetia- That's exactly what I did.

I tried to have patience but it took to long! :) -DW
 
I routinely use error handling to code around this. Error 76 is "path not found". Error 53 is "file not found". I'm pretty sure there is also an error number for "permission denied".

Did you hear about the Buddhist who refused Novocain during a root
canal? He wanted to transcend dental medication.
 
70 is "Permission Denied"

I tried to have patience but it took to long! :) -DW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top