当前位置: 移动技术网 > IT编程>开发语言>c# > C#中对文件进行选择对话框打开和保存对话框进行复制

C#中对文件进行选择对话框打开和保存对话框进行复制

2019年11月08日  | 移动技术网IT编程  | 我要评论

场景

通过文件选择对话框选择文件

 

 

 

复制文件到指定路径

 

 

 

注:

博客主页:

关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。

实现

打开选择文件对话框

openfiledialog importopenfiledialog = new openfiledialog();
dialogresult importdialogresult = importopenfiledialog.showdialog();

 

获取选择文件的路径

string xmlfilename = importopenfiledialog.filename;

 

获取选择文件对话框的点击按钮

dialogresult importdialogresult = importopenfiledialog.showdialog();
 if (importdialogresult == dialogresult.cancel)
                                {
                                    return;
                                }
 if (importdialogresult == dialogresult.ok)
                                {

                                }

 

选择保存文件目录对话框

folderbrowserdialog exportdialog = new folderbrowserdialog();
dialogresult exportdialogresult = exportdialog.showdialog();

 

选择保存文件目录对话框的点击按钮

 

 dialogresult exportdialogresult = exportdialog.showdialog();
                                    if (exportdialogresult == dialogresult.ok)
                                    {

         }

 

选择保存文件目录对话框选定的路径

 

exportpath = exportdialog.selectedpath;

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网