英雄卡图片附件未加载 [英] hero card image attachment not loading

查看:95
本文介绍了英雄卡图片附件未加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用代码

private static Attachment HeroCard() {
   var hc = new HeroCard {
      Images=new List<CardImage> {
         new CardImage(@"C:\Users\.....\imgs\testImage.jpg") }
      };
    return hc.ToAttachment();
}

将图像加载到英雄卡的附件中.这工作正常,但如果 我尝试使用本地文件夹代替e.x

To load an image in a hero card's attachment. This works fine but if I try to use the local folder instead e.x

@"~\imgs\testImage.jpg"

图像无法加载.我尝试了其他有关的其他格式 没有成功的道路.我想念什么?

The image fails to load. I have tried different other formats regarding the path with no success. What am I missing?

推荐答案

尝试使用本地文件夹@"~\imgs\testImage.jpg"

您的图片文件似乎存储在项目imgs文件夹中,并且您想将图片发送给客户端.您可以尝试使用System.Web.HttpContext.Current.Server.MapPath来读取MapPath.以下代码对我有用,请参考.

It seems that your image files are stored in your project imgs folder and you’d like to send the image to client. You can try to use System.Web.HttpContext.Current.Server.MapPath to read MapPath. The following code works for me, please refer to it.

var hc = new HeroCard
{
    Images = new List<CardImage> {
    new CardImage(System.Web.HttpContext.Current.Server.MapPath(@"~\imgs\testImage.jpg"))
}
};

这篇关于英雄卡图片附件未加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆