That may seem a bit obvious, but here's the situation: I have a Java program (Mirth Connect) which is processing medical record information, and one of the things I have it doing is invoking a .NET program (to do some things requiring Windows authentication that I had problems doing in Java/Javascript). The .NET program pulls settings from a settings file located in the directory it's invoked from; that is, from the directory where the Mirth Connect executable exists). I want to pull the settings from the directory where the .NET executable is, but short of hard-coding, I'm not sure how to find that directory.
Asked
Active
Viewed 180 times
0
-
2http://stackoverflow.com/questions/837488/how-can-i-get-the-applications-path-in-a-net-console-application – L.B Jan 12 '14 at 17:58
-
1I think this [SO thread](http://stackoverflow.com/questions/6041332/best-way-to-get-application-folder-path) pretty much covers all the scenarios. – Avi Turner Jan 12 '14 at 18:09
-
I looked around but didn't find that. Thanks! – Matt Gutting Jan 13 '14 at 13:47
2 Answers
0
To get the directory your EXE file is use:
AppDomain.CurrentDomain.BaseDirectory
To get the current directory
Evnironment.CurrentDirectory

AnthonyBCodes
- 342
- 2
- 13
-
Thanks; the thread above does answer the question but I appreciate your time. – Matt Gutting Jan 13 '14 at 13:49
0
In a .NET application, there is no fixed place where the configuration file should be. It could be anywhere. You should check it for the specific program. I would first check if the configuration file of the .NET program you call is on the same directory with the executable. This is not a guaranteed but it is the default scenario. If it is not there, you should find out where it is and then use that relative path in all of your installations.
Hope I am not missing something!

Pantelis Natsiavas
- 5,293
- 5
- 21
- 36
-
I wasn't looking for where I ought to look for the config file; I'm the one placing the config file. I wanted to know how the .NET program can find the directory it's in. The thread above answers my question. – Matt Gutting Jan 13 '14 at 13:50