c# 访问 app_themes 文件夹中的图像

c# access an image in app_themes folder

我的 App_Themes/Default 文件夹中有一张图像,我想将其加载到字节数组中。但是我在获取文件时遇到问题。有没有简单的 c# 方法可以做到这一点?

我的解决方案如下所示:

-项目
-App_Themes
-默认
-image1.png

您可以使用 Server.MapPath() 获取相对 url 的完整本地文件路径,例如:

string lFileName = Server.MapPath("~/App_Themes/Default/xyz.png");