如何从C#窗体中的资源文件获取图像路径? [英] How to get the image path from Resource file in c# windows forms?

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

问题描述

我想从c#windows应用程序中的资源文件夹中获取图像?我已经以不同的方式尝试过了。但我确实得到了正确的解决方案。

I want to get the image from Resource folder in c# windows application? already i tried in different ways. But i dint get the correct solution.

我需要路径:c:test \windowsapp\Resouces\bar.png而不是启动和可执行文件的路径等等。帮助我

i need the path: "c:test\windowsapp\Resouces\bar.png" instead of start-up and executable path etc.Help me

推荐答案

试试这个。

var filePath = System.Reflection.Assembly.GetExecutingAssembly().Location + "\\..\\..\\Resources\bar.png";

如果您的图片是有效资源,您可以通过以下方式访问它: Properties .Resources

If your image is a valid resource, you can access it through: Properties.Resources

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

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