我使用 ImageSharp 和 .Net Core 来处理一些图像。要加载图像和字体,我执行以下操作:
_image = Image.Load(@"Resources/imgs/quote_background.png");
_fonts = new FontCollection();
_font = _fonts.Install(@"Resources/fonts/Cousine-Italic.ttf");
// Image processing...
我的文件树看起来像:
- Solution
- - MyApp
- - - Controllers
- - - Models
- - - - Code.cs // This is where the above code is
- - - wwwroot
- - - Resources
- - - - imgs
- - - - fonts
当我通过 Visual Studio 启动应用程序时,它工作正常,它会找到图像。但是当我部署到 AWS 或本地 IIS 时,我收到以下错误:
DirectoryNotFoundException: Could not find a part of the path 'C:\inetpub\wwwroot\MyApp\Resources\imgs\quote_background.png'.
引用此图像的正确方法是什么?
谢谢