Ejecutar un ejecutable que está dentro del proyecto.

I have an exe application with i's required file and I've imported them into my VS C# project. I need to start the .exe process which is fine but I can't seem to get the path correct. Is there a way to reference local paths such as in html?

My visual studio solution structure:


I'm trying to get from Program.cs to COMTEST.exe basically.

preguntado el 12 de junio de 14 a las 10:06

local to what?, the exe folder, current working directory? -

@Sayse sorry, I wasn't clear. I've added my .exe to my solution project in VisualStudio. From a class in the root folder I'm trying to start the process running. I've put the directory layout of the visual studio solution in the origional post. -

1 Respuestas


String exePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),"AIRApplication", "COMTEST.exe");

The above code resolved 1/2 of the issue. The other 1/2 was that the exe was not being copied to the debug folder. Updating the 'Copy to Output Directory' option resolved this.

Respondido el 12 de junio de 14 a las 11:06

I've tried that from a number of posts on here. It's not giving me the correct path. I have the exe inside a folder in the project called "AIRApplication" and it's called "COMTEST.exe", it works fine if I use the full location from the C drive but obviously when this is moved onto a new computer it won't work. - Elliot Blackburn

That's giving me the path: "C:\\Users\\xxxxx\\Documents\\Visual Studio 2012\\Projects\\ConsoleApplication1\\ConsoleApplication1\\bin\\Debug\\AIRApplication\\COMTEST.exe" But the exe is in: C:\Users\SPARKOL04\Documents\Visual Studio 2012\Projects\ConsoleApplication1\ConsoleApplication1\AIRApplication\COMTEST.exe So it's not actually in the bin :S - Elliot Blackburn

You are having two issues. One is the path which my code fixes. The other issue is that the exe is not being copied to the debug folder. To enable this, select the COMTEST.exe within the solution, go to properties and select 'Copy Always' from the 'Copy to output Directory' option - Chris

Just select them all in the solution explorer, go to properties and select 'Copy Always' from the 'Copy to output Directory' option as before - Chris

Life saver, thanks Chris. I've not had to do this before, thanks for the quick responses! - Elliot Blackburn

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.