使VB2005对所有用户可用 [英] Make VB2005 available to all users

查看:54
本文介绍了使VB2005对所有用户可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我几乎完成了一个需要4-5个用户共享设置参数的实用程序.有什么方法可以告诉应用在公共共享文件夹中查找user.config文件吗?如果失败,该怎么办?

I just about finished a utility that needs the setup parameters shared among 4-5 users. Is there any way to tell the app to look for the user.config file in a common shared folder? Failing that, how else can this be done?

推荐答案

与VB2005无关.您永远不需要Visual Studio运行任何应用程序.您也没有获得重新分发它的合法权利.

现在,应基于应用程序的位置来计算此公用共享文件夹.这是您在运行时找到它的方式:

It has nothing to do with VB2005. You never need Visual Studio to run any applications. You also are not given have a legal right to re-distribute it.

Now, this common shared folder should be calculated based on the location of your application. This is how you find it during run-time:

System.IO.Path.GetDirectoryName(
    System.Reflection.Assembly.GetEntryAssembly().Location)



警告!还有许多其他方法可以找到此目录:从环境,入口点(主要)参数等.为了获得最大的兼容性,您需要使用我的方法;其他方法可能取决于如何托管程序集和其他细节.此方法查找当前正在运行的应用程序的入口程序集的主要可执行模块的路径.

—SA



Warning! There are many other ways to find out this directory: from Environment, entry point (main) parameters, etc. For maximum compatibility you need to use my method; other method may depend on how assembly is hosted and other detail. This method finds the path of the main executable module of the entry assembly of the currently running application.

—SA


正如"user.config"名称所暗示的那样,每个用户都有自己的配置文件副本.该文件应始终位于Application.LocalUserAppDataPath返回的路径中,如果是ClickOnce部署的应用程序,则该文件应位于%userprofile%\Local Settings下.

应始终在与使用该应用程序的.EXE相同的路径中找到"app.config"或在同一台计算机上运行该应用程序的每个人的公用文件.使用此文件夹的问题是普通用户不允许写入Program Files文件夹下的任何文件.需要对此文件进行的所有设置更改都必须以安装时间或具有admin privs的用户身份写入程序文件"下的应用程序文件夹.
As the "user.config" name implies, each user has their own copy fo the configuration file. This file should always be in the path returned by Application.LocalUserAppDataPath, or in the case of ClickOnce deployed apps, it''ll be under %userprofile%\Local Settings.

The "app.config", or the file common to everyone running the app on the same machine, should always be found in the same path as the .EXE that uses it. The problem with using this folder is that normal users are not allowed to write to any file under the Program Files folder. Any settings changes that need to be made to this file need to be written as install time or as a user with admin privs to the application folder under Program Files.


这篇关于使VB2005对所有用户可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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