在Compact Framework中删除readonly

在Compact Framework中删除文件的readonly属性的首选方法是什么,因为我们没有File :: SetAttributes?

您可以使用OpenNetCF 智能设备框架 ,该框架具有实现SetAttributesfunction的FileHelper类。

或者,如果您不想使用该路由,则可以PInvoke本机SetFileAttributes方法。

这也有效:

FileInfo fileInfo = new FileInfo(path); FileAttributes attributes = fileInfo.Attributes; if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { // set the attributes to nonreadonly fileInfo.Attributes &= ~FileAttributes.ReadOnly; }