如何从WPF中的文件夹路径获得的图像 [英] How to get image from a folder path in wpf

查看:540
本文介绍了如何从WPF中的文件夹路径获得的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解如何使一个从我的项目
的文件,我使用Visual Studio 2010,我在我的WPF项目文件夹被称为:图像

I'm trying to understand how to make a get a file from my project I'm using visual studio 2010, and I have a folder in my wpf project that is called: Images

我怎样才能从文件夹获取的图像,我'尝试:

How can I get an image from that folder, I'am trying:

return @"/Images/"+ name+".jpg";



文件夹它的自我是: C:\Users\Boaz -Pc\Documents\Visual工作室2010\Projects\FinalSadna\FinalSadna\Images

但它不为我工作。任何想法?

But it doesnt work for me. Any ideas?

推荐答案

你可以看看像这样

string imageName = name + ".jpg";
var path = Path.Combine(GetApplicationFolder(), "/Images/" + imageName);

如果你想通过大会找到它,你可以使用下面以及

if you want to find it via the Assembly you could use the following as well

var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

这篇关于如何从WPF中的文件夹路径获得的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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