zoukankan      html  css  js  c++  java
  • 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;
  • 相关阅读:
    python基础7
    python基础7
    十大经典预测算法(一)----线性回归
    RNN-循环神经网络
    CNN之经典卷积网络框架原理
    卷积神经网络CNN
    决策树的生成
    欠拟合、过拟合及解决方法
    决策树
    KD树
  • 原文地址:https://www.cnblogs.com/tianma3798/p/3698525.html
Copyright © 2011-2022 走看看