OpenFileDialog RestoreDirectory as no effect if Multiselect is set to true
We use OpenFileDialog
across our application to select files. So far, we never used Multiselect
. We set RestoreDirectory
to true so that any time we open the dialog we get the user to the last directory used. If I set Multiselect
to true, the directory from which the files are selected is not r开发者_Go百科emembered. The dialog shows the last directory used when Multiselect
was set to false. By the way, we create a new instance of OpenFileDialog
.
The environment:
Windows XP
VS 2008 targeting framework 3.5
C#
That's not what RestoreDirectory is designed to do. It makes sure that the program's default directory is restored when the dialog closes, even if the user navigated to another directory. The directory that is first selected by the dialog is selected by a registry key, written by Windows. The exact rules for that are murky and isn't the same for different versions of Windows.
If you want the dialog to open at a specific directory, be sure to set the InitialDirectory property.
If you go to your designer view your will find it "while adding OpenFileDialog Object visual studio have itself added initialDirectory property to it. Just go ahead and delete that link
精彩评论