首页 > Windows开发 > 详细

WPF打开或新建对话框

时间:2020-03-03 14:10:18      阅读:127      评论:0      收藏:0      [点我收藏+]

调出windows对话框新建文件

使用System.Windows.Forms.SaveFileDialog或者Microsoft.Win32.SaveFileDialog

System.Windows.Forms.SaveFileDialog saveFile = new System.Windows.Forms.SaveFileDialog();
            saveFile.Title = "新建文件";
            saveFile.FileName = "";
            saveFile.Filter = "*.txt";        //新建文件类型为txt
            
            string filename = string.Empty;
            if (saveFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                // Save document
                System.IO.FileStream fs = (System.IO.FileStream)saveFile.OpenFile();//输出文件
               
            }
            else
            {
                return;
            }

 

打开文件

使用System.Windows.Forms.OpenFileDialog 或者Microsoft.Win32.OpenFileDialog

System.Windows.Forms.OpenFileDialog openFile = new System.Windows.Forms.OpenFileDialog();
            openFile.Title = "打开文件";
            openFile.Filter = _filePathParameter.fileFilter();
            if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                TextValue = openFile.FileName;         //获取文件位置+文件名
            }

 

WPF打开或新建对话框

原文:https://www.cnblogs.com/ZM191018/p/12401889.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!