程序文件"下&QUOT文件的写权限的问题;夹 [英] file write permission issue under "Program Files" folder

查看:182
本文介绍了程序文件"下&QUOT文件的写权限的问题;夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的创新安装,使我的应用程序安装包,而我的应用程序写的是C#+ NET 2.0 + VSTS 2008 Inno Setup的=>的 http://www.jrsoftware.org/isinfo.php 并安装我在Program Files /美孚文件夹的应用程序(foo是我的应用程序的名称)。我的应用程序的目标是到Windows Vista。

我发现这个问题是我的程序不能写入该文件夹程序文件/美孚。我需要为了节省一些配置文件写入到该文件夹​​的权限。奇怪的事情,我注意到的是文件夹程序文件/美孚被标记为只读,我已经检查Program Files下的所有文件夹都标有只读,如Office。

我的问题是,

  1. 为什么所有的文件夹都被标记为只在Program Files文件阅读?这意味着我们不应该写在Program Files单独的应用程序文件夹?如果不是这样,我们应该将信息写入到磁盘如用户的具体应用的最后一次选择的配置信息?
  2. 如果我们能在Program Files文件写入到单独的应用程序文件夹,该如何解决?我不希望我的应用程序以管理员身份运行来解决这个问题,如果有解决办法写入该文件夹,我想要求如果可能的话最少的权限。
解决方案

您应该写为当前用户的用户特定的配置数据,应用程序数据文件夹,使用<一个href="http://msdn.microsoft.com/en-us/library/system.environment.specialfolder%28VS.100%29.aspx">special文件夹枚举和<一href="http://msdn.microsoft.com/en-us/library/14tx8hby%28VS.100%29.aspx">Enivronment.GetFolderPath.

I am using inno setup to make a installation package for my application, and my application is written by C# + .Net 2.0 + VSTS 2008. Inno setup => http://www.jrsoftware.org/isinfo.php and I install my application under Program Files/Foo folder (Foo is my application name). My application is targeting to Windows Vista.

The issue I found is my program cannot write to the folder Program Files/Foo. And I need the permission of write to this folder in order to save some configuration files. The strange thing I notice is the folder Program Files/Foo is marked as readonly and I have checked all folders under Program Files are marked with read only, such as Office.

My questions are,

  1. Why all folders are marked as read only under Program Files? It means we should not write to individual application folders under Program Files? If not, where should we write information to disk like user last selected configuration information of an individual application?
  2. If we could write to individual application folders under Program Files, what is the solution? I do not want my application to Run As administrator to solve this issue, and if there are solution to write to this folder, I want to require minimal permission if possible.

解决方案

You should write user specific config data to the Application Data folder for the current user, using the special folders enum and the Enivronment.GetFolderPath.

这篇关于程序文件&QUOT;下&QUOT文件的写权限的问题;夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆