public string[] DisplayFileDialog() { string[] result = null; try { Thread objThread = new Thread(state =>{ result = FnOpenFileDialog(); // TODO: do something with the returned result }); objThread.IsBackground = false; objThread.SetApartmentState(ApartmentState.STA); objThread.Start(); objThread.Join(); return result; } catch (Exception ex) { return result; } protected string[] FnOpenFileDialog() { IntPtr hdlr = GetForegroundWindow(); WindowWrapper Mockwindow = new WindowWrapper(hdlr); OpenFileDialog fDialog = new OpenFileDialog(); fDialog.Title = "Select Files"; fDialog.Multiselect = true; fDialog.CheckFileExists = true; fDialog.CheckPathExists = true; System.Windows.Forms.DialogResult dr = fDialog.ShowDialog(Mockwindow); string[] filenames = fDialog.FileNames; return filenames; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)