jjacksn
asked on
Getting the Calling Directory of an .exe
I am trying to use System.IO.Directory.GetCal lingDirect ory() to get the directory of my executable. Its returning a directory of not my executable. So I have two quetsions:
1. Is there a better way to determine the Calling Directory of the exe, or should I just make this call in the main constructor and save the value.
2. What / When / Why does this change from the actual CallingDirectory() of the exe
1. Is there a better way to determine the Calling Directory of the exe, or should I just make this call in the main constructor and save the value.
2. What / When / Why does this change from the actual CallingDirectory() of the exe
> should I just make this call in the main constructor and save the value.
1) Yes
2) GetCurrentDirectory returns the current working directory, not the originating directory of the application. So your application must somehow be changing the working directory before you are calling GetCurrentDirectory.
1) Yes
2) GetCurrentDirectory returns the current working directory, not the originating directory of the application. So your application must somehow be changing the working directory before you are calling GetCurrentDirectory.
Application.ExecutablePath
this will return what you want
this will return what you want
What I use is:
String path = Path.GetDirectoryName( Assembly.GetEntryAssembly(
My exes always reside in <AppFolder>\Bin\, therefore I remove the last Folder and keep this path in a SetUpHandler module at hand.
The Path object is in System.IO
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER