码迷,mamicode.com
首页 > Windows程序 > 详细

wpf打开文夹和打开文件

时间:2016-12-03 18:31:51      阅读:324      评论:0      收藏:0      [点我收藏+]

标签:tle   default   open   directory   row   .sh   选择   browser   com   

WPF调用WinForm中的 OpenFileDialog 和 FolderBrowserDialog 来实现响应的功能

 

技术分享
 OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Title = "选择文件";
            openFileDialog.Filter = "zip文件|*.zip|rar文件|*.rar|所有文件|*.*";
            openFileDialog.FileName = string.Empty;
            openFileDialog.FilterIndex = 1;
            openFileDialog.RestoreDirectory = true;
            openFileDialog.DefaultExt = "zip";
            DialogResult result = openFileDialog.ShowDialog();
            if (result == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }
            string fileName = openFileDialog.FileName;
            this.textBox1.Text = fileName;
技术分享
技术分享
 FolderBrowserDialog m_Dialog = new FolderBrowserDialog();
            DialogResult result = m_Dialog.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }
            string m_Dir = m_Dialog.SelectedPath.Trim();
            this.textBox1.Text = m_Dir;
技术分享

 

wpf打开文夹和打开文件

标签:tle   default   open   directory   row   .sh   选择   browser   com   

原文地址:http://www.cnblogs.com/damsoft/p/6129102.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!