if I want to get executable location what is the different between this command:
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Directory.GetCurrentDirectory();
System.Environment.CurrentDirectory;
is there any different ? is its pointed to different location ?
Assembly.GetExecutingAssembly().Location
Gets the location of the executing assembly. In an ASP.NET application this could vary due to shadow copying assemblies in system folders. The location of the currently executing assembly could be different than the location of the hosting process.
Directory.GetCurrentDirectory();
Gets the current working directory of the hosting process. In most cases this will be the directory where the executable is located but this working directory could be modified programatically using the SetCurrentDirectory method.
System.Environment.CurrentDirectory;
The directory from which the hosting process was started.
In a desktop application where you have everything in the same folder the 3 might return the same.
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
returns a folder of specified assembly.
Directory.GetCurrentDirectory()
gets the system current directory without backslash, according to MSDN. Directory.GetCurrentDirectory()
System.Environment.CurrentDirectory
gets or sets system current directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With