[英]C# Windows Form Application Unhandled Exception
I created a WFA for my friend's birthday, made a setup and sent the app to my friend.我为朋友的生日创建了一个 WFA,进行了设置并将应用程序发送给了我的朋友。 In the back end of the code I had to manually change the background wallpaper of the program on a button click and I used this.BackgroundImage = new Bitmap(@C:\Users\Admin\Desktop\Birthday_candles.jpg");
在代码的后端,我必须通过单击按钮手动更改程序的背景墙纸,我使用了 this.BackgroundImage = new Bitmap(@C:\Users\Admin\Desktop\Birthday_candles.jpg");
I did the same thing with System.Media.Player.SoundPlayer player = new System.Media.SoundPlayer();我对System.Media.Player.SoundPlayer player = new System.Media.SoundPlayer();做了同样的事情player.SoundLocation = @"C\Users\Admin\Downloads\Happy.wav";
player.SoundLocation = @"C\Users\Admin\Downloads\Happy.wav";
How do I add them on my setup file or something like this because if I delete, change location of those two components I get a "Unhandled exception has occured in your application. If you click Continue, the app will ignore this error and attempt to continue. If you click Quit, the app will close immediately."如何将它们添加到我的设置文件或类似内容中,因为如果我删除,更改这两个组件的位置,我会收到“您的应用程序中发生未处理的异常。如果单击继续,应用程序将忽略此错误并尝试继续。如果您单击退出,应用程序将立即关闭。”
Is there any solution with the code, setup or anything so it saves the files and keeps them even if the files are deleted or their address is changed.是否有任何代码、设置或任何解决方案,因此即使文件被删除或地址被更改,它也会保存文件并保留它们。
Thank you!谢谢!
You can embed the resources on the Properties > Resources.resx.您可以在 Properties > Resources.resx 上嵌入资源。 Accessing the image would look like as follows:
访问图像如下所示:
PanelName.Image = Properties.Resources.ImageName;
You can add the code snippet on a button click event.您可以在按钮单击事件上添加代码片段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.