【发布时间】:2011-09-08 22:03:05
【问题描述】:
我正在寻找我的应用程序的目录,它似乎与常规 c# 不同?
在Path.GetDirectoryName(Application.ExecutablePath) 中不起作用。
【问题讨论】:
我正在寻找我的应用程序的目录,它似乎与常规 c# 不同?
在Path.GetDirectoryName(Application.ExecutablePath) 中不起作用。
【问题讨论】:
试试Assembly.GetExecutingAssembly().Location
【讨论】:
一个正确的跨平台解决方案是
Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)
请注意,Environment.CurrentDirectory 和 Assembly.GetExecutingAssembly().Location(更准确地说,是它们的目录)在语义上是错误的,尽管它们经常——但并不总是——同一个目录:
Assembly.GetExecutingAssembly(),则会导致“/path/to/B.dll”。李>
【讨论】: