How do I change the Read-only file attribute for each file in a folder using c#?

前端 未结 4 1161
礼貌的吻别
礼貌的吻别 2021-02-14 18:11

How do I change the Read-only file attribute for each file in a folder using c#?

Thanks

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-14 18:54

    If you wanted to remove the readonly attributes using pattern matching (e.g. all files in the folder with a .txt extension) you could try something like this:

    Directory.EnumerateFiles(path, "*.txt").ToList().ForEach(file => new FileInfo(file).Attributes = FileAttributes.Normal);
    

提交回复
热议问题