Yaseen
Yaseen

Reputation: 628

How can I get path of setup.exe from custom action?

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

System.AppDomain.CurrentDomain.BaseDirectory;

return c:\Windows\syswow64\

Application.ExecutablePath;

return c:\Windows\syswow64\MsiExec.exe

Application.StartupPath

return c:\Windows\syswow64\

I need something return e:\

Upvotes: 1

Views: 1111

Answers (2)

Vivek Nuna
Vivek Nuna

Reputation: 1

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

You can get exe full path by reflection also.

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

You can this too.

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

One more way:

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

Upvotes: 1

Mostafiz
Mostafiz

Reputation: 7352

To get current working directory use

Directory.GetCurrentDirectory();

which locate under System.IO

Upvotes: 0

Related Questions