ฉันเห็นว่ามีบางวิธีในการรับเส้นทางโฟลเดอร์แอปพลิเคชัน:
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พึ่งพาการฉีด(ซึ่งมีสิ่งที่มีประโยชน์อื่น ๆ )