Environment.CurrentDirectory vs System.Reflection

Of the following methods, to get the working directory of the executing assembly, is there a recommendation that is considered best practice? I heard from my developers that method 1 does not work on Windows 7 SP1 64-bit sometimes, unless it runs with elevated permissions ( Run as administrator ). But method 2 works all the time. Is there a reason why the first of them sometimes fail?

Method 1:

System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location())

Method 2:

Environment.CurrentDirectory
+5
source share
1 answer

Environment.CurrentDirectoryis a way to go the way it is to get a working directory. Using reflection is also possible slower.

: : A , , Environment.CurrentDirectory , , Environment.CurrentDirectory , (, / ).

+6

All Articles