How do I get the current path?
Printable View
How do I get the current path?
Directory.GetCurrentDirectory() for getting the current working directory or,
System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase property if you need the directory where your executable file is stored...
Martin
adding to martin,
Application.ExecutablePath gives you the executable path.
:D
Hi!
Try this:
Assembly assembly = Assembly.GetExecutingAssembly();
string fileName = assembly.Location;
Assembly assembly = Assembly.GetExecutingAssembly();
string fileName = assembly.Location;
Seems this will return the assembly path. So if your code is in a library, it will be the path of the library, not the path of the calling executive file.
Use Assembly.GetCallingAssembly instead if you want to find the calling executive path.
I guess originally RYE reffered to application's current path ;) :D
10x a lot.
Yes, I reffered to application's current path, but how can I get it without the exe?
What manipulation on Application.ExecutablePath can I do inorder to get it without the exe in the end?
the thing is .NET Assembley /DLL is always associated with some .exe either way. you can't run the dll on its own. so you will need to consider exe.
what all you are trying to do anyway;)