无处不在的方式来获得根目录中的应用程序是通过C#运行根目录、无处不在、应用程序、方式

2023-09-07 04:48:24 作者:魂俅

我的应用程序需要,我可以访问文件系统。不管在code Web服务器或一个控制台应用程序上运行,我如何能得到根目录下的应用程序运行在类似于C:\ TheApplication ...

My application requires that I have access to the file system. Regardless if the code runs on a web server or a console app, how can I get the root directory the application is running in. Something like C:\TheApplication...

谢谢!

推荐答案

最简单的大概是:

System.Reflection.Assembly.GetExecutingAssembly().Location

希望这有助于

Hope this helps,

-Oisin