获取安装过程中应用程序路径 [英] Getting Application path during the installation

查看:124
本文介绍了获取安装过程中应用程序路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IM部署应用程序和用户后,在安装过程中选择安装我想获得该路径的应用程序,即时通讯在自定义操作已,但我不知道怎么去哪里了将要安装应用程序的路径!

im deploying an application and during the installation after the user choose where to install the app i want to get that path , im in a custom action already but i dont know how to get the application path where its going to be installed !

它的Windows窗体和IM使用Visual Studio 2010C#发展。

its Windows Forms and im developing using Visual studio 2010 "C#".

和IM使用默认的部署工具...

and im using the default deploying tool...

任何想法?

感谢...

推荐答案

类自定义操作是应该System.Configuration.Installer.Installer继承。这有一个参数,它叫做语境其中有一个参数字典。这本词典包含了一些关于安装,你可以添加一些有用的变量。

The class your custom action is in should inherit from System.Configuration.Installer.Installer. This has a parameter on it called Context which has a Parameters dictionary. The dictionary contains a number of useful variables about the install and you can add some.

一旦你添加的自定义安装程序中的自定义操作你的痛苦安装项目。选择安装操作和CustomActionData属性设置为:

Once you have added the custom installer to your install project in the Custom Actions pain. Select the Install action and set the CustomActionData property to:

/targetdir="[TARGETDIR]\"

然后就可以像这样访问路径:

Then you can access the path like this:

[RunInstaller(true)]
public partial class CustomInstaller : System.Configuration.Install.Installer
{
    public override void Install(System.Collections.IDictionary stateSaver)
    {
        base.Install(stateSaver);
        string path = this.Context.Parameters["targetdir"]; 
        // Do something with path.
    } 
}

这篇关于获取安装过程中应用程序路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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