Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using Microsoft.Win32;
- using System.Windows.Forms;
- namespace OpenFileOrFolder
- {
- /// <summary>
- /// Логика взаимодействия для MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- private void selectFileBtn_Click(object sender, RoutedEventArgs e)
- {
- Microsoft.Win32.OpenFileDialog fileDialog = new Microsoft.Win32.OpenFileDialog();
- if(fileDialog.ShowDialog().Value != false)
- {
- filePath.Text = fileDialog.FileName;
- }
- }
- // same result
- private void selectWinFormsFileBtn_Click(object sender, RoutedEventArgs e)
- {
- System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog();
- if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- winFormsFilePath.Text = fileDialog.FileName;
- }
- }
- // ugly dialog, improved in .NET 3.0
- private void selectFolderBtn_Click(object sender, RoutedEventArgs e)
- {
- FolderBrowserDialog folderDialog = new FolderBrowserDialog();
- if(folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- folderPath.Text = folderDialog.SelectedPath;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment