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

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

问题描述

类人猿、睡莲和明轮!

我正在使用 VS 2008 在 C#/.NET/WPF 中开发 Windows 桌面应用程序.需要在 Vista 和 XP 机器上安装和运行该应用程序.我正在使用安装程序/Windows 安装程序项目来安装应用程序.

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.

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

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!).

我原以为解决方案很简单.Vista 和 XP 都有用于此目的的共享应用程序数据文件夹.(Vista 中的ProgramData",XP 中的Documents and SettingsAll UsersApplication Data".).NETEnvironment.GetFolderPath(SpecialFolder.CommonApplicationData) 调用存在以查找给定 PC 上这些文件夹的路径,是的,是的!

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 SettingsAll UsersApplication Data" in XP.) The .NET Environment.GetFolderPath(SpecialFolder.CommonApplicationData) call exists to find the paths to these folders on a given PC, yes, yes!

但我不知道如何在 Setup 项目中将 shared-application-data 文件夹指定为目标.

安装项目提供了一个Common Files"文件夹,但它用于共享程序组件(不是数据文件),通常位于Program Files"下,并且与Program files"中的其他任何内容都具有相同的安全限制" 是的,是的!

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!

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

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!

是否可以通过 VS 2008 安装项目以强大的跨 Windows 版本方式将文件添加到 shared-app-data 文件夹?谁能告诉我怎么做?

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!

要将内容放在 VS2008 安装项目的 Common Application Data 文件夹的子目录中,您可以执行以下操作:

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

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

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

右键单击目标机器上的文件系统"并选择添加特殊文件夹 -> 自定义文件夹".

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

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

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.)

将文件夹的 DefaultLocation 属性更改为[CommonAppDataFolder][Manufacturer][ProductName]".请注意与应用程序文件夹的 DefaultLocation 属性的相似之处,包括单反斜杠的奇怪使用.

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.

惊叹于一个荒谬(但不可否认)的事实,即有一个名为Property"的文件夹属性.

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

将文件夹的属性属性更改为COMMONAPPDATAFOLDER".

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

放置在Common Application Data"文件夹中的数据文件将被复制到ProgramDataManufacturerProductName"(在 Vista 上)或Documents and SettingsAll UsersApplication DataManufacturerProductName"(在 XP 上)) 安装程序运行时.

Data files placed in the "Common Application Data" folder will be copied to "ProgramDataManufacturerProductName" (on Vista) or "Documents and SettingsAll UsersApplication DataManufacturerProductName" (on XP) when the installer is run.

现在事实证明,在 Vista 下,非管理员无法修改/写入此处的文件.因此,所有用户都可以读取这些文件,但他们也可以在Program Files"中读取这些文件.那么,我想知道 Common Application Data 文件夹的重点是什么?

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天全站免登陆