如何发布带有图像的应用程序 [英] How to publish application with image

查看:37
本文介绍了如何发布带有图像的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是个愚蠢的问题,但请告诉我如何发布带有图像的应用程序?我正在使用

I know this is stupid question but please tell me how to publish application with images? I am using

this.BackgroundImage = Image.FromFile("../../images/Blue/Blue_Style1.jpg"); 

它在 Visual Studio 中工作正常,但是当我发布应用程序图像时不包含并且应用程序给出错误

it works fine in visual studio but when I publish application images doesn't include and application gives error

推荐答案

解决方案 1: 在您的项目中创建一个用于存储 images 的专用文件夹 debug/发布文件夹.

Solution 1: Create a dedicated folder for storing the images in your project debug/release folder.

例如:project/bin/Release/Images/

从该文件夹访问图像,如下所示:

Access the Images from that folder as below:

String FullPath=System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Replace("file:\\", "")+"\\Images\\Blue_Style1.jpg";
this.BackgroundImage =Image.FromFile(FullPath);

解决方案 2:Resources 文件访问 Images.
注意:首先您需要将 Images 添加到 Resources 中.
在这里,我已将 Blue_Style1.jpg 文件添加到 Resources.

Solution 2: accessing Images from Resources file.
Note: first you need to add the Images into Resources.
Here i have added Blue_Style1.jpg file to Resources.

this.BackgroundImage = Properties.Resources.Blue_Style1;

请参阅此处以将图像添加到资源

这篇关于如何发布带有图像的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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