我看到有一些方法可以获取应用程序文件夹路径:
Application.StartupPathSystem.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location)AppDomain.CurrentDomain.BaseDirectorySystem.IO.Directory.GetCurrentDirectory()Environment.CurrentDirectorySystem.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)System.IO.Path.GetDirectory(Application.ExecutablePath)
根据情况,最佳方法是什么?
IHostEnvironment.ContentRootPath,我们有了可靠的,可以通过注入的IHostEnvironment依赖项(包含其他有用的东西)进行访问。