获取 Windows 窗体应用程序执行目录的路径 [英] Get path to execution directory of Windows Forms application
问题描述
我想获取 Windows 窗体应用程序执行目录的路径.(即可执行文件所在的目录.)
I would like to get the path to the execution directory of a Windows Forms application. (That is, the directory in which the executable is located.)
有人知道 .NET 中的内置方法可以做到这一点吗?
Does anyone know of a built-in method in .NET to do this?
推荐答案
Application.Current results in an appdomainhttp://msdn.microsoft.com/en-us/library/system.appdomain_members.aspx
Application.Current results in an appdomain http://msdn.microsoft.com/en-us/library/system.appdomain_members.aspx
这也应该给你程序集的位置
Also this should give you the location of the assembly
AppDomain.CurrentDomain.BaseDirectory
我似乎记得有多种方法可以获取应用程序的位置.但是这个至少在过去对我有用(我已经有一段时间没有完成 winforms 编程了:/)
I seem to recall there being multiple ways of getting the location of the application. but this one worked for me in the past atleast (it's been a while since i've done winforms programming :/)
这篇关于获取 Windows 窗体应用程序执行目录的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!