我的程序甚至打开文件都需要管理员权限,这正常吗?
当我将 .NET 程序安装到 C:\Program Files 并运行它时,它不会要求管理员权限 (Win7),但它无法打开应用程序目录中的任何文件,除非我手动授予它管理员权限。如果不在 C 上,则效果很好。
我知道我可以将自定义清单文件添加到我的应用程序中以询问用户管理权限,但它总是会询问,即使不需要。
我读到该软件在安装后不应向程序文件写入任何内容,但它甚至无法读取文件(例如,语言文件)。我也有一个数据库文件,由程序读写,那么我应该把这个文件放在哪里呢?
所以我想知道在没有管理员权限的情况下无法读取文件是否正常。如何让程序仅在必要时才请求管理员权限?
编辑我以系统管理员身份登录。
When I install my .NET program to C:\Program Files and I run it, it doesn't ask for Admin Rights (Win7), but it can't open any file in the application's directory unless I give admin rights to it manually. If it's not on C, it works well.
I know I can add a custom manifest file to my application to ask the user for admin rights, but it'd ask it always, even when it's not required.
I read on SO that that the software shouldn't write anything to Program Files after it has been installed, but it can't even read a file (for example, language files). I have a database file too, which is read and written by the program, so where should I place this file?
So I'm wondering if it is normal not to have access to read a file without admin rights. How can I make the program ask for admin rights only if it's necessary?
EDIT I'm logged on as system admin.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
普通用户没有 Progrem Files 文件夹的写入权限。但是,您应该能够读取(内容)文件。如何打开供阅读的文件?
正确的方法是使用指定的文件夹。使用 WinForms 会是这样的
A normal User does not have write privileges in the Progrem Files folder. You should be able to read (content) files however. How do you open you for-reading files?
The proper way is to use a designated folder. Using WinForms that would be something like