开发者

OpenFileDialog RestoreDirectory as no effect if Multiselect is set to true

开发者 https://www.devze.com 2022-12-25 19:41 出处:网络
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 directo

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

0

精彩评论

暂无评论...
验证码 换一张
取 消