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

前端 未结 3 1429
星月不相逢
星月不相逢 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:21

    This is what I found with a google search.

    File.SetAttributes(filePath, File.GetAttributes(filePath) & ~(FileAttributes.ReadOnly));
    

    Obviously this is for only one file so you will have to loop over the files and set the attributes for each.

提交回复
热议问题