winform怎么在安装程序中获取所在路径?

在继承了 Installer 的安装程序类中,如何获取安装包的目录,和程序要安装到的目录。

 我试过  System.Windows.Forms.Application.StartupPath 和  System.AppDomain.CurrentDomain.BaseDirectory

得到的都是在 system32 目录。

要安装到的目录 也不正确。

  • kirayamto - 1年前

    安装程序要安装到的路径通过下面方法获取

    Custom Actions 下对应的Actions 的属性中设置

    CustomActionData 这个属性为 /targ="[TARGETDIR]\"

    Actions 的代码中调用

    string targ = Context.Parameters["targ"];

    获取目标路径。

    至于你安装包所在目录,可能是通过SourceDir 这个属性来获取的,你可试试看