为什么尝试从 ProgramFiles/MyApp 读取文件时出现访问被拒绝的情况?

发布于 2024-09-24 05:10:22 字数 206 浏览 1 评论 0原文

我试图从 ProgramFiles/MyApp 中的配置文件中读取数据,但在 Windows 7 中它会抛出拒绝访问的异常,对于 ProgrammData/MyApp 中的文件来说是相同的:

fileStream = new FileStream(this.StorageName, FileMode.Open ,文件访问.读取);

是不是只能从这些文件夹中读取?

I am trying to read from a config file in ProgramFiles/MyApp but in Windows 7 it throws an exception for Access denied, it is the same and for a file in ProgrammData/MyApp:

fileStream = new FileStream(this.StorageName, FileMode.Open, FileAccess.Read);

Is not it allowed to read only from these folders?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

日暮斜阳 2024-10-01 05:10:22

看看这个:
http://social. msdn.microsoft.com/forums/en-us/windowsgeneraldevelopmentissues/thread/53660459-EC32-4819-9213-5190F5A1B885

这似乎是UAC问题,您应该根据nmahajan重新定位您的信息。

这个更好:
http://social.msdn。 microsoft.com/Forums/en/windowsgeneraldevelopmentissues/thread/dd28741a-1025-4ca2-a88b-95a5ea156e7f

引用 GTVic:

1 - C:\Users\用户名\Documents
2 - C:\Users\用户名\AppData\Local
3 - C:\Users\用户名\AppData\Roaming
4 - C:\Users\Public\Documents
5 - C:\ProgramData
用于:
1 - 登录到一台特定计算机时一个用户私有的数据
用户可以通过浏览其文档文件夹轻松找到数据库文件

2 - 登录到一台特定计算机时一个用户私有的数据
数据库文件位于隐藏文件夹中,但熟练用户可以访问

3 - 登录到任何联网计算机时,一个用户的私有数据
数据库文件位于隐藏文件夹中,但熟练用户可以访问

4 - 数据对登录到特定计算机的任何用户公开
用户可以通过浏览公共文档文件夹轻松找到数据库文件

5 - 数据对登录到特定计算机的任何用户公开
数据库文件位于隐藏文件夹中,但熟练用户可以访问

take a look at this:
http://social.msdn.microsoft.com/forums/en-us/windowsgeneraldevelopmentissues/thread/53660459-EC32-4819-9213-5190F5A1B885

it seems to be an UAC issue, and you should relocate your information according to nmahajan.

This one is even better:
http://social.msdn.microsoft.com/Forums/en/windowsgeneraldevelopmentissues/thread/dd28741a-1025-4ca2-a88b-95a5ea156e7f

Quoting GTVic:

1 - C:\Users\username\Documents
2 - C:\Users\username\AppData\Local
3 - C:\Users\username\AppData\Roaming
4 - C:\Users\Public\Documents
5 - C:\ProgramData
Use for:
1 - data private to one user while logged onto one specific computer
the database files can be easily found by the user by browsing their Documents folder

2 - data private to one user while logged onto one specific computer
the database files are in a hidden folder but may be accessible by a skilled user

3 - data private to one user while logged onto any networked computer
the database files are in a hidden folder but may be accessible by a skilled user

4 - data public to any user logged onto a specific computer
the database files can be easily found by the user by browsing the public Documents folder

5 - data public to any user logged onto a specific computer
the database files are in a hidden folder but may be accessible by a skilled user

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文