I created a simple console application with the following code:
Console.WriteLine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
Console.WriteLine(System.AppDomain.CurrentDomain.BaseDirectory);
Console.WriteLine(System.Environment.CurrentDirectory);
Console.WriteLine(System.IO.Directory.GetCurrentDirectory());
Console.WriteLine(Environment.CurrentDirectory);
I copied the resulting executable to C:\temp2
. I then placed a shortcut to that executable in C:\temp3
, and ran it (once from the exe itself, and once from the shortcut). It gave the following outputs both times:
C:\temp2
C:\temp2\
C:\temp2
C:\temp2
C:\temp2
While I'm sure there must be some cockamamie reason to explain why there are five different methods that do virtually the exact same thing, I certainly don't know what it is. Nevertheless, it would appear that under most circumstances, you are free to choose whichever one you fancy.
UPDATE:
I modified the Shortcut properties, changing the "Start In:" field to C:\temp3
. This resulted in the following output:
C:\temp2
C:\temp2\
C:\temp3
C:\temp3
C:\temp3
...which demonstrates at least some of the distinctions between the different methods.