Reputation: 2827
I would like to create a generic shortcut that points to the .exe
within the debug folder.
This is how it looks:
Target: %windir%\system32\cmd.exe /c start Debug\testproject.exe
The problem I face is the following:
The program uses a relative path to pick one file from the folder.
StaticPath = @"./Data/Static.xml";
So when the program starts from the shortcut it raises an exception because of invalid path.
Ein Teil des Pfades "S:\XXX\Projekte\XXX\XXX\XXX\testproject\bin\Data\Static.xml" konnte nicht gefunden werden
(the path could not be found, German...)
The link is placed in the bin folder, that's maybe why the program tries to find the Static.xml
from there ignoring the Debug
path.
Any idea how to create a generic link that works with a relative path?
Upvotes: 0
Views: 195
Reputation: 387795
The problem is that the program is executed from the shortcut’s location, so its working directory is not the same as the executable’s location (i.e. you’re outside the Debug folder).
You have three options:
Change the way the program accesses the file by always looking into the Data
folder that’s relative to the executing assembly’s location. So it doesn’t matter from where you call the program, it will always look for the folder that is next to the .exe
.
Change the directory before calling the program, so it does take the Debug
folder into account:
cmd.exe /c cd Debug & start testproject.exe
Change the application to take the path to the file as a command line argument and explicitly pass the path.
Upvotes: 1