如何从自定义操作获取setup.exe的路径? [英] How can I get path of setup.exe from custom action?

查看:97
本文介绍了如何从自定义操作获取setup.exe的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在e:\ setup.exe中的setup.exe,我尝试了以下代码:

My setup.exe in e:\setup.exe, I tried this code:

System.AppDomain.CurrentDomain.BaseDirectory;

返回c:\ Windows \ syswow64 \

return c:\Windows\syswow64\

Application.ExecutablePath;

返回c:\ Windows \ syswow64 \ MsiExec.exe

return c:\Windows\syswow64\MsiExec.exe

Application.StartupPath

返回c:\ Windows \ syswow64 \

return c:\Windows\syswow64\

我需要一些返回e:\

I need something return e:\

推荐答案

using System.IO;
string exeDir = Directory.GetCurrentDirectory();

您也可以通过反射获得exe的完整路径.

You can get exe full path by reflection also.

string exeLocation = System.Reflection.Assembly.GetEntryAssembly().Location;

您也可以.

string exeDir = AppDomain.CurrentDomain.BaseDirectory;
string exeLocation = Assembly.GetEntryAssembly().Location;

另一种方式:

string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);

这篇关于如何从自定义操作获取setup.exe的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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