选择文件对话框:
private void button_chose_Click(object sender, RoutedEventArgs e)
{
var openFileDialog = new Microsoft.()
{
Filter = "Excel Files (*.sql)|*.sql"
};
var result = ();
if (result == true)
{
this.textblock_filename.Text = ;
}
}
选择文件夹对话框:WPF中似乎没有打开文件夹对话框,不过可以通过winform的方法打开,调研之前需要引用;
代码:
private void button_runScript_Click(object sender, RoutedEventArgs e)
{
FolderBrowserDialog m_Dialog = new FolderBrowserDialog();
DialogResult result = m_Dialog.ShowDialog();
if (result == )
{
return;
}
string m_Dir = m_Dialog.();
this.textblock_filename.Text = m_Dir;
}
全部代码:
using System;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
namespace MysqlScriptDemo
{
/// <summary>
/// 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void button_chose_Click(object sender, RoutedEventArgs e)
{
var openFileDialog = new Microsoft.()
{
Filter = "Excel Files (*.sql)|*.sql"
};
var result = ();
if (result == true)
{
this.textblock_filename.Text = ;
}
}
private void button_runScript_Click(object sender, RoutedEventArgs e)
{
FolderBrowserDialog m_Dialog = new FolderBrowserDialog();
DialogResult result = m_Dialog.ShowDialog();
if (result == )
{
return;
}
string m_Dir = m_Dialog.();
this.textblock_filename.Text = m_Dir;
}
}
}