def EzFileOpenDialog(initialFile=None, multiselect=False): dlg = OpenFileDialog() dlg.Multiselect = multiselect dlg.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*" if initialFile: dlg.InitialDirectory = Directory.GetParent( initialFile) #Path.GetFileName(initialFile) if dlg.ShowDialog() == True: return dlg.FileNames
def FileOpenDialog(initialFile=None,multiselect=False): dlg = OpenFileDialog() dlg.Multiselect = multiselect dlg.DefaultExt = ".txt"; # Default file extension dlg.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; if initialFile: dlg.InitialDirectory = System.IO.Path.GetDirectoryName(initialFile) dlg.FileName = System.IO.Path.GetFileName(initialFile) #Directory.GetParent(initialFile) #Path.GetFileName(initialFile) if dlg.ShowDialog() == True: return dlg.FileNames