How to get Application Startup Path And Installation Path?

Peace be Upon You,

First of all i mean by startup path; the path of the exe of your application, and for the installation path; the path to where your application will be installed using an installer project.

1- Startup Path:

If you used Environment.CurrentDirectory or Directory.GetCurrentDirectory() you will find that the returned path is affected by any open file dialog you might have opened during running your application, so it won’t return to you the application actual startup path.

You can use this instead AppDomain.CurrentDomain.BaseDirectory which will always return you the application startup path.

2-Installation Path:

You can get this by doing the following steps:

  • Make a CustomActionInstaler class
  • Point to it from the installer project
  • Open the CustomActions view from the installer and then go to the properties of the CustomActionInstaller that we just pointed to in the previous step.
  • There is a property named by CustomActionData set it to /targetdir=”[TARGETDIR]\”. The key “targetdir” will be used later for getting the installer application directory and the actual value is “TARGETDIR” but the square brackets and slash are for empty spaces in the application path.
  • Call Context.Parameters[“TargetDir”], this will return to you the installation path of your application.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s