Running another application from C# code in another folder with spaces

Trips

Well-known member
Joined
Aug 7, 2010
Messages
2,788
Hi all.
Ive got a .exe file with some dlls etc in a folder called "My Folder". When i double click that exe the program just works fine.
Then im trying to run that program from another program ran in the folder that contains "My Folder" (this program is a launcher).
The problem is that even if i specify correctly the file path (my final .exe is launched, but throws an exception), the working directory or something is not "My folder" and i think that is needed to the properly work of my final application.
How can i correctly launch my final program from the other?
My code is :
<div style="background-color:white; color:black
<pre>Process.Start(<span style="color:#a31515 """+<span style="color:#a31515 @"My FolderMyFinalProgram.exe"+<span style="color:#a31515 """);

[/code]

And ive tried things like:
<div style="background-color:white; color:black
<pre>ProcessStartInfo pStartInfo = <span style="color:blue new ProcessStartInfo();

pStartInfo.WorkingDirectory =<span style="color:#a31515 """ + <span style="color:#a31515 @"My Folder" + <span style="color:#a31515 """;

pStartInfo.Domain = <span style="color:#a31515 """ + <span style="color:#a31515 @"My Folder" + <span style="color:#a31515 """;

pStartInfo.FileName = <span style="color:#a31515 """ + <span style="color:#a31515 @"My FolderMyFinalProgram.exe" + <span style="color:#a31515 """;

Process.Start(pStartInfo);

[/code]


Thanks in advance.

View the full article
 
Back
Top