Dot-Net
獲取 Windows 窗體應用程序執行目錄的路徑
我想獲取 Windows 窗體應用程序的執行目錄的路徑。(即執行檔所在的目錄。)
有誰知道.NET 中的內置方法可以做到這一點?
Application.Current 導致 appdomain <http://msdn.microsoft.com/en-us/library/system.appdomain_members.aspx>
這也應該給你裝配的位置
AppDomain.CurrentDomain.BaseDirectory我似乎記得有多種方法可以獲取應用程序的位置。但這至少在過去對我有用(我已經有一段時間沒有做過winforms程式了:/)
在 VB.NET 中
Dim directory as String = My.Application.Info.DirectoryPath在 C# 中
string directory = AppDomain.CurrentDomain.BaseDirectory;