Saved C # paths OpenFileDialog

In my application, I have two places where the user needs to select a file. In both cases, the files are in different directories, but they are usually the same between runs.

By default, OpenFileDialog is used by default for the last directory used, but it is useless to me, as it is almost always the wrong folder, and I end up alternating between the two folders. I would like for some way the first dialogue to remember the path that was used the last time it was opened, and the second to remember your own path.

Example: path A is C: \ foo \ bar \ something \ x.dll, path B is C: \ foo \ baz \ whatever \ y.xml

Dialog a opens and I select A, then dialog b opens (default A), and I need to go back to B. When I open the application dialog again, it opens (default B), and I go back to A .

I would like to avoid all this extra navigation by remembering the paths separately. Is there a good way to do this?

+4
source share
1 answer

When you open each dialog box, simply set the InitialDirectory dialog box to the folder that was last used for this dialog.

Of course, this will require maintaining a directory for each dialog, but it will provide the behavior you are looking for.

+5
source

Source: https://habr.com/ru/post/1315215/


All Articles