Remove readonly in Compact Framework

允我心安 提交于 2019-12-05 03:59:30

You could use the OpenNetCF Smart Device Framework, which has a FileHelper class that implements the SetAttributes function.

Or if you don't want to go that route, you could PInvoke the native SetFileAttributes method.

This also works:

FileInfo fileInfo = new FileInfo(path);
FileAttributes attributes = fileInfo.Attributes;

if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
{
    // set the attributes to nonreadonly
    fileInfo.Attributes &= ~FileAttributes.ReadOnly;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!