Possible Duplicate:
How can I get the application's path in .NET in a console app?
Hi,
I would like to find the absolute path from where my exe file is running.
i.e if i run my application/exe from c:\my-app\myapp.exe then it should return c:\my-app.
My target is to find my database location inside the db folder.开发者_Go百科
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase
gives you the name of the exe, and System.IO.Path.GetDirectoryName(...)
then pulls the directory part out.
See http://msdn.microsoft.com/en-us/library/aa457089.aspx#howtoexecutingapppath_topic2
精彩评论