1
可能重复:
How can I get the application's path in .NET in a console app?如何找到EXE文件的绝对路径在vb.net
嗨,
我想找个绝对路径从我的exe文件运行的地方。
即即使我从c:\ my-app \ myapp.exe运行我的应用程序/ exe,那么它应该返回c:\ my-app。
我的目标是在db文件夹中找到我的数据库位置。
可能重复:
How can I get the application's path in .NET in a console app?如何找到EXE文件的绝对路径在vb.net
嗨,
我想找个绝对路径从我的exe文件运行的地方。
即即使我从c:\ my-app \ myapp.exe运行我的应用程序/ exe,那么它应该返回c:\ my-app。
我的目标是在db文件夹中找到我的数据库位置。
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase
给你的exe的名称,然后System.IO.Path.GetDirectoryName(...)
然后拉出目录部分。
请参阅http://msdn.microsoft.com/en-us/library/aa457089.aspx#howtoexecutingapppath_topic2