Skip to content

Instantly share code, notes, and snippets.

@Miragecore
Last active February 24, 2020 23:11
Show Gist options
  • Save Miragecore/e0bc03096248109c1564a2dcce7aece4 to your computer and use it in GitHub Desktop.
Save Miragecore/e0bc03096248109c1564a2dcce7aece4 to your computer and use it in GitHub Desktop.
OpenFileDialog c#
using System;
using System.IO;
using System.Windows;
using Microsoft.Win32;
namespace WpfTutorialSamples.Dialogs
{
public partial class OpenFileDialogSample : Window
{
public OpenFileDialogSample()
{
InitializeComponent();
}
private void btnOpenFile_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
if(openFileDialog.ShowDialog() == true)
txtEditor.Text = File.ReadAllText(openFileDialog.FileName);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment