VS2008安装项目:共享(所有用户)应用程序数据文件? [英] VS2008 Setup Project: Shared (By All Users) Application Data Files?

查看:195
本文介绍了VS2008安装项目:共享(所有用户)应用程序数据文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在C#/。NET / WPF中使用VS 2008开发一个Windows桌面应用程序。该应用程序是必需的在Vista和XP机器上安装和运行。我正在使用安装程序/ Windows Installer Project安装该应用程序。



我的应用程序需要读取/修改/写入SQLCE数据库文件(.sdf)和一些其他与我正在使用的第三方控件相关的数据库类型文件。这些文件应该在PC上的所有用户/登录之间共享,所有这些文件都不需要作为管理员。这意味着当然这些文件不能进入程序自己的安装目录(这样的事情通常在Vista的到来之前,是的,是的!)。



<我曾经期望解决方案很简单。 Vista和XP都有用于此目的的共享应用程序数据文件夹。(\ProgramData在Vista中,\Documents and Settings\All Users\Application Data在XP中。 ).NET Environment.GetFolderPath(SpecialFolder.CommonApplicationData)调用存在以找到给定PC上这些文件夹的路径,是的,是的!



但是我无法确定如何在安装项目中指定共享应用程序数据文件夹作为目标。



安装项目提供了一个公共文件文件夹,但这是用于共享程序组件(而不是数据文件),通常位于\Program Files下,并且在\Program文件中具有相同的安全限制,是的, p>

安装项目提供了一个用户应用程序数据文件夹,但这是一个每个用户的文件夹,这正是我要避免的,是的,是的! p>

是否可以向共享添加文件从VS 2008安装项目以强大的跨Windows版本方式的d-app-data文件夹?有谁能告诉我怎么样?

解决方案

我已经通过其他来源了解了我的问题的答案,是的,是的!可悲的是,它没有解决我的问题!这是什么让我 - 一个固定器上?是的,是的!



要从VS2008安装项目将东西放在通用应用程序数据文件夹的子目录中,请执行以下操作:


  1. 右键单击解决方案资源管理器中的安装项目,然后选择查看 - >文件系统。


  2. 右键单击目标机器上的文件系统,然后选择添加特殊文件夹 - >自定义文件夹。


  3. 重命名自定义文件夹到通用应用程序数据文件夹。 (这不是用于生成的文件夹的名称,只是为了帮助您保持直线)。


  4. 将文件夹的DefaultLocation属性更改为[COMMONAPPDATAFOLDER] [生产] \ [产品名称]。请注意与应用程序文件夹的DefaultLocation属性的相似性,包括单个反斜杠的奇怪使用。


  5. 在荒谬(但不可否认)事实上,有一个名为属性的文件夹属性。


  6. 将文件夹的Property属性更改为COMMONAPPDATAFOLDER。


放置在通用应用程序数据文件夹中的数据文件将被复制到\ProgramData\Manufacturer\ProductName(在Vista上)或\Documents and Settings\All Users\Application Data \Manufacturer\ProductName(在XP上)当安装程序运行时。



现在,事实证明,在Vista下,非管理员不会修改/写入访问这里的文件。所以所有的用户都可以读取这些文件,但是他们也可以在\Program Files中找到这些文件。那么我想知道什么是Common Application Data文件夹的要点?


fellow anthropoids and lily pads and paddlewheels!

I'm developing a Windows desktop app in C#/.NET/WPF, using VS 2008. The app is required to install and run on Vista and XP machines. I'm working on a Setup/Windows Installer Project to install the app.

My app requires read/modify/write access to a SQLCE database file (.sdf) and some other database-type files related to a third-party control I'm using. These files should be shared among all users/log-ins on the PC, none of which can be required to be an Administrator. This means, of course, that the files can't go in the program's own installation directory (as such things often did before the arrival of Vista, yes, yes!).

I had expected the solution to be simple. Vista and XP both have shared-application-data folders intended for this purpose. ("\ProgramData" in Vista, "\Documents and Settings\All Users\Application Data" in XP.) The .NET Environment.GetFolderPath(SpecialFolder.CommonApplicationData) call exists to find the paths to these folders on a given PC, yes, yes!

But I can't figure out how to specify the shared-application-data folder as a target in the Setup project.

The Setup project offers a "Common Files" folder, but that's intended for shared program components (not data files), is usually located under "\Program Files," and has the same security restrictions anything else in "\Program files" does, yes, yes!

The Setup project offers a "User's Application Data" folder, but that's a per-user folder, which is exactly what I'm trying to avoid, yes, yes!

Is it possible to add files to the shared-app-data folder in a robust, cross-Windows-version way from a VS 2008 setup project? Can anyone tell me how?

解决方案

I have learned the answer to my question through other sources, yes, yes! Sadly, it didn't fix my problem! What's that make me -- a fixer-upper? Yes, yes!

To put stuff in a sub-directory of the Common Application Data folder from a VS2008 Setup project, here's what you do:

  1. Right-click your setup project in the Solution Explorer and pick "View -> File System".

  2. Right-click "File system on target machine" and pick "Add Special Folder -> Custom Folder".

  3. Rename the custom folder to "Common Application Data Folder." (This isn't the name that will be used for the resulting folder, it's just to help you keep it straight.)

  4. Change the folder's DefaultLocation property to "[CommonAppDataFolder][Manufacturer]\[ProductName]". Note the similarity with the DefaultLocation property of the Application Folder, including the odd use of a single backslash.

  5. Marvel for a moment at the ridiculous (yet undeniable) fact that there is a folder property named "Property."

  6. Change the folder's Property property to "COMMONAPPDATAFOLDER".

Data files placed in the "Common Application Data" folder will be copied to "\ProgramData\Manufacturer\ProductName" (on Vista) or "\Documents and Settings\All Users\Application Data\Manufacturer\ProductName" (on XP) when the installer is run.

Now it turns out that under Vista, non-Administrators don't get modify/write access to the files in here. So all users get to read the files, but they get that in "\Program Files" as well. So what, I wonder, is the point of the Common Application Data folder?

这篇关于VS2008安装项目:共享(所有用户)应用程序数据文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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