简体   繁体   English

未经授权的访问例外-如何获得访问权限?

[英]Unauthorisedaccessexception - how to gain access?

I have a winform application to compress and move some files. 我有一个winform应用程序来压缩和移动一些文件。 When I try to access a path on my desktop, I get an unauthorisedaccess exception. 当我尝试访问桌面上的路径时,出现未经授权的访问异常。 I am running visual studio as administrator (says that in the program bar) and I am a full admin on my machine (can access other accounts, etc). 我以管理员身份运行Visual Studio(说在程序栏中),并且我是计算机的完全管理员(可以访问其他帐户等)。

How can I acess this path (folder)? 如何访问此路径(文件夹)? One of the problems I have is the folder keeps setting itself to readonly. 我遇到的问题之一是文件夹将自身设置为只读。

Thanks 谢谢

The readonly flag can be cleared by anyone with write access. 具有写访问权限的任何人都可以清除readonly标志。 If that is all then you will just need to set file attributes. 如果仅此而已,则只需要设置文件属性即可。 However if the files ACL is blocking you (and it is easy to create an ACL that does not allow administrators) your options are more limited. 但是,如果文件ACL阻止了您(并且很容易创建不允许管理员使用的ACL),则您的选择将受到更大的限制。

Start by finding out why the file keeps being set to read only, because if something else is updating the file you will have to coordinate with that other process otherwise all sorts of problems are likely to occur. 首先找出为什么文件保持设置为只读的原因,因为如果有其他更新文件,则您将不得不与其他进程进行协调,否则可能会发生各种问题。

Best tool to see what is happening to a file is Process Monitor from SysInternals . SysInternals的 Process Monitor查看文件状况的最佳工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM