当Directory.Move子文件夹和父文件夹时,IOException访问被拒绝 [英] IOException access denied when Directory.Move subfolder and parent folder
本文介绍了当Directory.Move子文件夹和父文件夹时,IOException访问被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图重命名具有子文件夹的多个文件夹,但是当我在子文件夹上使用Directory.Move()时,父文件夹似乎被锁定了.
I am trying to rename multiple folders that have subfolders, but when I use Directory.Move() on a subfolder the parent folder seem to get locked up.
我的代码:
var pathParent = @"D:\test\f1";
var pathSub = @"D:\test\f1\f2";
var pathParentnew = @"D:\test\f1new";
var pathSubnew = @"D:\test\f1\f2new";
Directory.Move(pathSub, pathSubnew);
Directory.Move(pathParent, pathParentnew);
最后一个Directory.Move(
)抛出
IOException:对"D:\ test \ f1"的访问被拒绝
IOException: Access to "D:\test\f1" is denied
有人知道我可以重命名两个文件夹吗?
Does anyone know how I can rename both folders?
推荐答案
我弄清楚了问题所在.我必须在Windows中关闭文件资源管理器.该过程以某种方式锁定了文件夹.
I figured out what the problem was. I had to close File Explorer in Windows. The process was locking up the folders somehow.
这篇关于当Directory.Move子文件夹和父文件夹时,IOException访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文