wpf打开文夹和打开文件
Posted 晓明的哥哥
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了wpf打开文夹和打开文件相关的知识,希望对你有一定的参考价值。
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打开文夹和打开文件的主要内容,如果未能解决你的问题,请参考以下文章