[英]mono c# get application path
I am looking to get the directory of my application it seems to be different from regular c#?我正在寻找我的应用程序的目录,它似乎与常规的 c# 不同?
As in Path.GetDirectoryName(Application.ExecutablePath)
is not working.如
Path.GetDirectoryName(Application.ExecutablePath)
不工作。
One correct and cross-platform solution would be一种正确的跨平台解决方案是
Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)
Note that both Environment.CurrentDirectory
and Assembly.GetExecutingAssembly().Location
(more exactly, the directory thereof) are semantically wrong even though they are often - but not always - the same directory:请注意,
Environment.CurrentDirectory
和Assembly.GetExecutingAssembly().Location
(更准确地说,是其目录)在语义上都是错误的,即使它们经常——但并非总是——同一个目录:
Assembly.GetExecutingAssembly()
, it would result in "/path/to/B.dll".Assembly.GetExecutingAssembly()
,则会导致“/path/to/B.dll”。Try Assembly.GetExecutingAssembly().Location
尝试
Assembly.GetExecutingAssembly().Location
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.