问题描述
我想获得Windows Forms应用程序的执行目录的路径。 (也就是可执行文件所在的目录)
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结果在一个appdomain
Application.Current results in an appdomainhttp://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窗体应用程序的执行目录的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!