Get the path to another executable inside the same solution

I am using C #, VS 2005.

I have one solution with two projects.

Project1 needs to start project2 after some checks.

How to get the executable path of Project2 from Project1?

I need a solution for both debugging and live mode.

thanks,

The cop

+4
source share
2 answers

The exe for the second project should have a predictable location relative to the first exe. Obtaining the absolute path for the folder containing your first EXE is easy:

string myPath = System.Reflection.Assembly.GetEntryAssembly().Location; string myDir = System.IO.Path.GetDirectoryName(myPath); 

Then add the relative path of your second exe. It is recommended that you save it in the same directory as the 1st,

  string path = System.IO.Path.Combine(myDir, "project2.exe"); System.Diagnostics.Process.Start(path); 

The easiest way to get this to work both in the IDE and on the target machine is to let the IDE copy project2.exe. Right-click project1, Add Link, Projects tab, select Project2. The Copy Local property for the link will be True, so project2.exe will be in the same directory as project1.exe

+3
source

If you set the Project2 output directory to a known location for Debug and Release configurations, you can use that famous location in your Project1.

0
source

Source: https://habr.com/ru/post/1309545/


All Articles