removing readonly from folder, its sub folders and all the files in it

前端 未结 3 1397
星月不相逢
星月不相逢 2021-01-22 02:56

is there a way that i can remove the property \"read only\"?

i tried this:

var di = new DirectoryInfo(\"C:\\\\Work\");
                di.Attributes &         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-22 03:30

    Almost, try:

    var di = new DirectoryInfo("C:\\Work");
    
    foreach (var file in di.GetFiles("*", SearchOption.AllDirectories)) 
        file.Attributes &= ~FileAttributes.ReadOnly;
    

提交回复
热议问题