I am trying to make a file path inside of the folder above the executable. For instance, I am wanting the variable TAGPATH
to be the filepath to an executable in the folder C:\User\ApplicationFolder\tag_rw\tag_rw.exe
while the application is in C:\User\ApplicationFolder\AppFiles
. I want the application to be portable, meaning no matter the folder names it will retrieve the filepath of the application's executable then go to the parent folder and navigate into tag_rw\tag_rw.exe
.
I basically want string TAGPATH = @"path_to_appfolder\\tag_rw\\tag_rw.exe"
Here is what I have tired so far (using the first answer How to navigate a few folders up? ):
string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
string TAGPATH = System.IO.Path.GetFullPath(System.IO.Path.Combine(appPath, @"..\"));
I am getting a run-time error ArgumentException
with the description URI formats are not supported.
Is there an easier/better way to go about this?
Thank you!