首页 > 代码库 > WPF 打开文件 打开路径对话框
WPF 打开文件 打开路径对话框
WPF调用WinForm中的 OpenFileDialog 和 FolderBrowserDialog 来实现响应的功能
对应的引用程序集:
using System.Windows.Forms;
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;
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。