我正在尝试从我的项目资源中获取图像,并将其转换为n WPF应用程序中的图片,然而,当我到达图像时,我得到了一条无法跟踪的路径。("P:\Projects\DocumentHandling\PictureHandler\bin\Debug\DocumentHandlingTouch.exe....\Resources\pdf1.jpg")图片不显示。显示了使用以下代码的图片,但不是来自资源部分的图片。
Picture p = new Picture();
t.Content = filePath.Value;
p.ToolTip = t;
//External Program
if (Path.GetExtension(filePath.Key.ToString()) == ".pdf")
{
var path = System.Reflection.Assembly.GetExecutingAssembly().Location + @"\..\..\Resources\pdf1.jpg";
p.ImagePath = path;
}我的路径设置是不是错了?每当需要pdf文件时,我都需要显示此图像。该程序显示数据库中的图片。但如果它是pdf格式的,显然它不会显示任何东西,所以我想显示它的图像。
发布于 2014-12-12 03:32:54
如果您希望从参考资料加载图像,请按照此处的说明进行操作:Dynamically adding and loading image from Resources in C#
https://stackoverflow.com/questions/27427977
复制相似问题