我知道这是一个愚蠢的问题,但是请告诉我如何发布带有图像的应用程序?我在用
this.BackgroundImage = Image.FromFile("../../images/Blue/Blue_Style1.jpg");
它在Visual Studio中工作正常,但是当我发布应用程序图像时不包含该应用程序,并且应用程序给出了错误
解决方案1:创建一个专用文件夹将其存储images
在您的项目debug/release
文件夹中。
前任: project/bin/Release/Images/
从该文件夹访问图像,如下所示:
String FullPath=System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Replace("file:\\", "")+"\\Images\\Blue_Style1.jpg";
this.BackgroundImage =Image.FromFile(FullPath);
解决方案2:Images
从Resources
文件访问。
注意:首先,您需要将添加Images
到中Resources
。
在这里,我已将Blue_Style1.jpg
文件添加到Resources
。
this.BackgroundImage = Properties.Resources.Blue_Style1;
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句