Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 清除Windows Mobile 6 Professional中的只读标志_C#_Windows_Mobile - Fatal编程技术网

C# 清除Windows Mobile 6 Professional中的只读标志

C# 清除Windows Mobile 6 Professional中的只读标志,c#,windows,mobile,C#,Windows,Mobile,我正在编写WM6+的应用程序,并试图覆盖现有文件: File.Copy(src, dest, true); 但我得到了这个错误: System.UnauthorizedAccessException: UnauthorizedAccessException at System.IO.__Error.WinIOError() at System.IO.File.InternalCopy() at System.IO.File.Copy() 因此,我尝试更改目标文件上的文件属性,以便能够覆盖它:

我正在编写WM6+的应用程序,并试图覆盖现有文件:

File.Copy(src, dest, true);
但我得到了这个错误:

System.UnauthorizedAccessException: UnauthorizedAccessException
at System.IO.__Error.WinIOError()
at System.IO.File.InternalCopy()
at System.IO.File.Copy()
因此,我尝试更改目标文件上的文件属性,以便能够覆盖它:

System.IO.File.SetAttributes(dest, FileAttributes.Normal);
但当我尝试编译时,我得到了以下结果:

Error   1   'System.IO.File' does not contain a definition for 'SetAttributes'  L:\Admin\Applications_Source_Code\CommonTime_AEP_Config_Source\AEP_WM6 - Production Code\AEP_WM6\Form1.cs   133 26  AEP_WM6
为什么SetAttributes不存在

这是我试图覆盖的文件(不是系统文件,只是在路径相关的情况下显示):

这似乎成功了(感谢Greatco的评论)将我指到这里:


这个问题的解决方案是使用OpenNETCF框架。比如,

OpenNETCF.IO.FileHelper.SetAttributes("filePath ise here", FileAttributes.Normal);

我不知道它是否相同,但我知道在Windows Phone 8上,您必须使用独立存储库。你不能简单地保存到手机上,因为你无权访问硬盘的某些部分。隔离存储库使您的资料保持本地和安全。@AMR Windows Mobile 6与Windows 98一样安全。我建议您看看这个问题:它似乎与您的一样。问题是.NET 3.5 Compact没有File::SetAttributes。谢谢@TheGreatCO你指给我的帖子成功了!我在原始问题中添加了链接和解决方案。我已编辑了您的标题。请参阅“”,其中的共识是“不,他们不应该”。
FileInfo fileInfo = new FileInfo(dest); 
FileAttributes attributes = fileInfo.Attributes; if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) 
{ 
    // set the attributes to nonreadonly 
    fileInfo.Attributes &= ~FileAttributes.ReadOnly; 
} 
OpenNETCF.IO.FileHelper.SetAttributes("filePath ise here", FileAttributes.Normal);