打开文件对话框RestoreDirectory因为没有影响

打开文件对话框RestoreDirectory因为没有影响

本文介绍了打开文件对话框RestoreDirectory因为没有影响,如果多选设置为true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们用打开文件对话框在我们的应用程序选择文件。到目前为止,我们从来没有使用过多选。我们制定 RestoreDirectory 来真正让我们打开的对话​​框中的任何时候,我们得到了用户使用的最后一个目录。如果设置了多选为真,从中选择文件的目录不会被记住。该对话框显示了多选设置为false上次使用的目录。顺便说一句,我们创建打开文件对话框一个新的实例。

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 remembered. The dialog shows the last directory used when Multiselect was set to false. By the way, we create a new instance of OpenFileDialog.

环境:

Windows XP的

Windows XP

VS 2008的目标框架3.5

VS 2008 targeting framework 3.5

C#

推荐答案

这不是RestoreDirectory是专门做。它确保当在对话框关闭,即使用户导航到另一个目录中的程序的默认的目录被恢复。即首先由对话框中选择的目录被选中一个注册表项,写由视窗。对于确切的规则是黑暗的,而不是相同的不同版本的Windows。

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.

如果你想在对话框打开,在一个特定的目录,一定要设置InitialDirectory属性。

If you want the dialog to open at a specific directory, be sure to set the InitialDirectory property.

这篇关于打开文件对话框RestoreDirectory因为没有影响,如果多选设置为true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 16:38