• WPF文件和文件夹的操作


    1、对文件的操作

        private void button_chose_Click(object sender, RoutedEventArgs e)  
        {  
            var openFileDialog = new Microsoft.Win32.OpenFileDialog()  
            {  
            DefaultExt =".sql", Filter
    = "Excel Files (*.sql)|*.sql|All files(*.*)|*.*" }; var result = openFileDialog.ShowDialog(); if (result == true) { this.textblock_filename.Text = openFileDialog.FileName; } }

    2、文件夹的操作,选择文件夹对话框:WPF中似乎没有打开文件夹对话框,不过可以通过winform的方法打开,调研之前需要引用System.Windows.Forms;

    private void button_runScript_Click(object sender, RoutedEventArgs e)  
    {  
        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.textblock_filename.Text = m_Dir;  
    } 
  • 相关阅读:
    asp.net2.0系列视频教程
    Android入门教程(三十一)SQLite分页读取(转)
    sql语句大全
    判断是不是ie浏览器 加上ie11
    字节面试题
    泛型
    线程和
    sysbench工具
    自定义集合类
    类型通配符
  • 原文地址:https://www.cnblogs.com/lunawzh/p/5861069.html
Copyright © 2020-2023  润新知