OpenFileDialog openFileDialog = new OpenFileDialog { Filter = "TXT file (*.txt)|*.txt" }; string fileContent = ""; if (openFileDialog.ShowDialog() == true){ fileContent = System.IO.File.ReadAllText(openFileDialog.FileName); }