“访问被拒绝”当使用copyFile函数时,“moveFile”在相同的目录下正常工作 [英] "Access denied" when using copyFile function, however, "moveFile" is working fine on the same directories

查看:330
本文介绍了“访问被拒绝”当使用copyFile函数时,“moveFile”在相同的目录下正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将目录A \B复制到目录A \C。

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

目录A \B已经存在,原因很明显,目录A \C还不存在。

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

当copyFile函数用于将目录A \B复制到A \C时,我会收到一个访问被拒绝错误,并且不会复制该目录过度。

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.

但是,当我尝试复制单个文件时, A \B \hello.txt into A \C\hello.txt,该函数正常工作。

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.

此外,当moveFile函数用于将目录A \B复制到目录A \C,它似乎工作正常。有没有任何想法?谢谢。 :)

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. :)

推荐答案

copyFile不会为您创建目录。

copyFile will not create a directory for you.

您必须确保该目录存在,然后才能复制该文件或使用 CreateDirectory

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

关于CreateDirectory的注意事项
1)它将只创建目标路径。
2)如果目录存在则返回错误,因此您需要处理错误。

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.

这篇关于“访问被拒绝”当使用copyFile函数时,“moveFile”在相同的目录下正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆