Can anyone tell me what's the difference between System.CurrentDomain.AppDomain.BaseDirectory
and Directory.GetCurrentDirectory()
in C#, please??
See AppDomain on MSDN and also Directory.GetCurrentDirectory() on MSDN .
According to this question the difference is that
System.AppDomain.CurrentDomain.BaseDirectory returns current directory, not executable location, ie when run from outlook (sent as a link to \\server\\folder\\file.exe it will set BaseDirectory to user documents instead executable location from Jakub Pawlinski whereas
Directory.GetParent(Assembly.GetExecutingAssembly().Location)
gets the parent folder of the current execting assembly.
So the code I'm using now is:
string location = Assembly.GetExecutingAssembly().Location;
if (location != null)
{
string config = Path.Combine(Directory.GetParent(location).FullName, "Config.xml"));
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.