我正在构建包含CardImage的HeroCard,该Image必须显示一张图像。到目前为止,我一直在使用
HeroCard hcBody = new HeroCard
{
Text = "IMG",
Images = new List<CardImage> {
new CardImage(url: $"https://www.example.com/Pictures/" + picNo + ".jpg") },
Buttons = new List<CardAction> {
new CardAction(ActionTypes.ImBack, "SELECT"+picNo , value: picvalue) },
};
msg.Attachments.Add(hcBody.ToAttachment());
这是带有文字的HeroCard,从URL加载的图像会动态添加图像编号,并在其类型末尾添加图像编号。然后我添加一个带有动作,文本和值的按钮
现在的问题是,我需要从项目的路径中加载图像。我试图通过
实现var picPath=System.Configuration.ConfigurationManager.AppSettings["picServerPath"];
并将CardImage网址修改为
Images = new List<CardImage> { new CardImage(url: picPath+ picNo + ".jpg") }
使用记录器,我看到构建的路径正确,但HeroCard出现了,但是图像丢失了。因此,如果我想在服务器上使用项目的路径,我想需要以不同的方式创建CardImage的URL?
您需要确保在创建CardImage时使用的每个URL都是有效的absolute