积极答复者
[WPF开发] 如何用C#+XAML实现打开文件夹的功能?

问题
答案
-
好吧,自己解决了:
System.Diagnostics.Process.Start("explorer.exe",System.Environment.CurrentDirectory);
- 已标记为答案 ZetianChiang 2014年10月29日 1:52
全部回复
-
請參考以下
private void Button_Click(object sender, RoutedEventArgs e) { // Configure open file dialog box Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); string currentPath = System.AppDomain.CurrentDomain.BaseDirectory; dlg.InitialDirectory = currentPath; // initial Path dlg.DefaultExt = ".txt"; // Default file extension dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension // Show open file dialog box Nullable<bool> result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { // Open document txtFileName.Text = dlg.FileName; } }
Myblog: 松露筆管麵
-
請參考以下
private void Button_Click(object sender, RoutedEventArgs e) { // Configure open file dialog box Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); string currentPath = System.AppDomain.CurrentDomain.BaseDirectory; dlg.InitialDirectory = currentPath; // initial Path dlg.DefaultExt = ".txt"; // Default file extension dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension // Show open file dialog box Nullable<bool> result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { // Open document txtFileName.Text = dlg.FileName; } }
Myblog: 松露筆管麵
你好 神來之筆,
感谢你的回答,不过这个代码应该是打开.txt选择器的对话框,我是想实现类似Visual Studio中工程单击右键,选择“在文件资源管理器中打开文件夹”这样的功能,弹出的是文件夹,这样该如何实现呢?
-
好吧,自己解决了:
System.Diagnostics.Process.Start("explorer.exe",System.Environment.CurrentDirectory);
- 已标记为答案 ZetianChiang 2014年10月29日 1:52