RKM
RKM

Reputation: 3241

"Access denied" when using copyFile function, however, "moveFile" is working fine on the same directories

I am copying Directory A\B into Directory A\C.

Directory A\B already exists for obvious reasons, and directory A\C does not yet exists.

When the copyFile function is used to copy directory A\B to A\C, I get a "access denied" error, and the directory does not get copied over.

However, when I tried copying over a single file, e.g. A\B\hello.txt into A\C\hello.txt, the function is working fine.

Also, when the "moveFile" function is used to copy Directory A\B into Directory A\C, it seems to be working fine. Does anyone have any ideas? Thanks. :)

Upvotes: 1

Views: 1348

Answers (1)

Prathamesh Gharat
Prathamesh Gharat

Reputation: 514

copyFile will not create a directory for you.

you'll have to make sure the directory exists before you copy the file or create it using CreateDirectory

Things to note about CreateDirectory 1) It'll only create the final directory in the destination path. 2) Returns error if directory exists, so you'll need to handle the error.

Upvotes: 2

Related Questions