问题描述
我有这样的打包路径:
"pack://application:,,//MyApplication.Resources; component/Resources/Pictures/{0} .png";
"pack://application:,,,/MyApplication.Resources;component/Resources/Pictures/{0}.png";
我用来加载用户选择的图像(用户从组合框选择).
which I use to load user selected images (user selects from a combo box).
在尝试加载图像之前,如何检查图像是否存在?
How can I check if the image exists before I try to load it?
通常我会执行File.Exists(PATH),但这不是PATH.我该如何使用打包路径?
Normally I would do File.Exists(PATH), but this is not a PATH. How do I do this with pack paths?
谢谢.
请 标记为已回答 如果这回答了您的问题,或者 未标记为已回答 (如果没有).
很高兴为您提供帮助:)
我的网站
Please Mark as Answered If this answers your question OrUnMark as Answered if it did not.
Happy to Help :)
My Site
推荐答案
您可以尝试使用
var resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
列出所有嵌入式资源的名称,并检查其中是否包含您想要的名称.
to list all the names of the embedded resources, and check if it contains the name you want.
希望这对您有所帮助.
这篇关于如何检查文件是否存在打包路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!