问题描述
我尝试编写一个控制台应用程序C#将txt文件移动到其他文件夹
该功能只是将某些.txt文件从文件夹A复制到文件夹AA
字符串来源="C:\\ A \\ ResultClassA.txt";
File.Move(Source,"C:\\ AA");
但始终提示错误消息:
拒绝访问该路径.
故障排除提示:
确保您具有访问此资源的足够特权.
如果您尝试访问文件,请确保该文件不是ReadOnly.
获取此异常的一般帮助.
在执行"File.move"代码之前,我真的需要将文件夹A和文件夹B设置为不只读"属性吗?并设置为仅在成功移动后回读?
有什么主意吗?
谢谢.
通过Hero
Hi,
I try to write a console app C# to move my txt files to other folder
The functions is just copy certain .txt files from folder A to folder AA
string source = "C:\\A\\ResultClassA.txt";
File.Move(Source, "C:\\AA");
but its alway prompt error message:
Access to the path is denied.
Troubleshooting tips:
Make sure you have sufficient privileges to access this resource.
If you are attempting to access a file, make sure it is not ReadOnly.
Get general help for this exception.
Do i really need to set my folder A and folder B to "NOT ReadOnly" attribute before "File.move" code are execuse? and set to read only back after success moved?
any idea?
Thanks.
By Hero
推荐答案
这篇关于如何将txt文件移动到其他文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!