How to remove a single Attribute (e.g. ReadOnly) from a File?

前端 未结 7 1777
南方客
南方客 2020-11-28 08:54

Let say, a file has the following attributes: ReadOnly, Hidden, Archived, System. How can I remove only one Attribute? (for example ReadOnly)

7条回答
  •  清歌不尽
    2020-11-28 09:31

    if ((oFileInfo.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
        oFileInfo.Attributes ^= FileAttributes.ReadOnly;
    

提交回复
热议问题