CSharp examples for System.Windows.Forms:Dialog
Try File Path with OpenFileDialog
using System.Windows.Forms; using System.Windows; using System.Linq; using System.Collections.Generic; public class Main{ public static bool TryFilePath(string dialogTitle, string filter, out string fileName) {/*from ww w . ja v a 2s. c o m*/ var fileSelector = new OpenFileDialog() { Title = dialogTitle, Filter = filter, Multiselect = false, CheckFileExists = true, DefaultExt = filter.Split('|').ElementAt(1).Replace("*", "") // It SHOULD be an extension method, so todo }; if (fileSelector.ShowDialog() == DialogResult.OK) { fileName = fileSelector.FileName; return true; } else { fileName = string.Empty; return false; } } }