2

I have a button which will open a file dialog and choose 2 certificates.
enter image description here After i click the button a windows will be shown from where i choose two certificates.enter image description here

I click Open so i will get this two certs. What i want to do is that after i click Open and click again the Select Certificate button instead the empty filename textbox like this enter image description here I want the last selection to be saved. Is it possible such a thing?

drgmak
  • 1,135
  • 10
  • 13
  • You mean you want to automatically re-select the previously selected items? – stuartd Jun 08 '16 at 14:02
  • Yes, you are right. – drgmak Jun 08 '16 at 14:02
  • I know how to remember the directory, but not how to find the selected files. – drgmak Jun 08 '16 at 14:04
  • Save the FileName string & set it before opening a second time. Note that there is a bug with this only setting part of the file name - workaround here http://stackoverflow.com/questions/17163784/default-name-with-openfiledialog-c – PaulF Jun 08 '16 at 14:07

2 Answers2

4

OpenFileDialog has a FileName property
Just assign it

paparazzo
  • 44,497
  • 23
  • 105
  • 176
2

Assign the FileName property when you create the dialog. It supports multiple files if you include quotes around the file names (full paths). See the example below:

var dialog = new OpenFileDialog
{
    Multiselect = true,
    FileName = @"""C:\example.txt"" ""C:\example2.txt"""
};