簡體   English   中英

如何從自定義操作中獲取 setup.exe 的路徑?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM