从文件夹、其子文件夹和其中的所有文件中删除只读 [英] removing readonly from folder, its sub folders and all the files in it
本文介绍了从文件夹、其子文件夹和其中的所有文件中删除只读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法删除只读"属性?
is there a way that i can remove the property "read only"?
我试过这个:
var di = new DirectoryInfo("C:\\Work");
di.Attributes &= ~FileAttributes.ReadOnly;
但它不起作用
推荐答案
差不多,试试:
var di = new DirectoryInfo("C:\\Work");
foreach (var file in di.GetFiles("*", SearchOption.AllDirectories))
file.Attributes &= ~FileAttributes.ReadOnly;
这篇关于从文件夹、其子文件夹和其中的所有文件中删除只读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文