[英]How can I get path of setup.exe from custom action?
我在 e:\setup.exe 中的 setup.exe,我试过这段代码:
System.AppDomain.CurrentDomain.BaseDirectory;
返回 c:\Windows\syswow64\
Application.ExecutablePath;
返回 c:\Windows\syswow64\MsiExec.exe
Application.StartupPath
返回 c:\Windows\syswow64\
我需要一些东西 return e:\
using System.IO;
string exeDir = Directory.GetCurrentDirectory();
您也可以通过反射获取 exe 完整路径。
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);
获取当前工作目录使用
Directory.GetCurrentDirectory();
位于System.IO
下
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.