使用打开文件对话框覆盖系统资源文件夹中的图像时出现问题 [英] problem in overriding the image in the system resources folder using open file dialog

查看:109
本文介绍了使用打开文件对话框覆盖系统资源文件夹中的图像时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名学习c#并且正在学习wnform的学生。我有一个winform,它有一个启动窗体,从资源文件夹加载其背景图像。在启动画面和主软件之后有一个设置,我有一个按钮,以便可以在打开文件对话框的帮助下更改启动画面。所以我想它应该用用户选择的图像替换资源文件夹中的图像splashimage.jpg。我想将选择使用的图像复制到资源文件夹并删除上一个图像,并将新复制的图像的图像重命名为splashimage.jpg我有这个代码,但它不起作用资源文件夹中的图像没有改变我在打开文件对话框中选择的图像我不知道它为什么不工作



i am a student studying c# and working on wnform. i have a winform which have a splash form which loads its background image from the resources folder. and after the splash screen and in the main software there is a setting from which i have a button so that the splash screen can be changed with the help of open file dialog. so i want that it should replace the image splashimage.jpg in the resource folder with the image the user selected. i want to copy the image the use selected to the resource folder and remove the previous image and rename the image of the newly copied image to the splashimage.jpg i have this code but it does not work the image in the resource folder is not changing with the image which i have selected in the open file dialog i dont know why it is not working

var FD = new System.Windows.Forms.OpenFileDialog();
                FD.Filter = "jpeg files|*.jpg";
                if (FD.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                   System.IO.File.Copy(FD.FileName,Application.StartupPath
+ "\\" + splashimage.jpg", true);
                }

推荐答案

可能的原因可能是泼水形式加载的''splashimage.jpg''正在使用中,因此你无法取代它。



检查你的启动表格,在执行复制操作之前卸载了splashimage。或者至少将你加载的图像文件处理到启动表单。
The possible reason could be the ''splashimage.jpg'' loaded by the splash form is in use and hence you cannot replace it.

Check your splash form which loads the splashimage is disposed before you perform the copy operation. or atleast dispose the image file you loaded to the splash form.


这篇关于使用打开文件对话框覆盖系统资源文件夹中的图像时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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