我想一个SaveFileDialog有以下行为:
I'd like a SaveFileDialog with the following behavior:
第一次打开它,它关系到我的文档。
The first time you open it, it goes to "My Documents".
之后,它会到最后选择的文件夹。 什么是实现这一目标的最好方法是什么?
Afterwards, it goes to the last selected folder. What's the best way to accomplish this?
如果我没有设置InitialDirectory,它进入exe文件的目录 - 这不是我想要的。它rememebers最后选定的目录,虽然 - 甚至执行之间
If I don't set the InitialDirectory, it goes to the exe's directory - which is not what I want. It rememebers the last selected directory though - even between executions.
如果我设置了InitialDirectory,它不记得最后选定的目录。当然,我可以保存在注册表中的最后选择的目录:(但我在寻找一个更好的解决方案。
If I set the InitialDirectory, it does not remember the last selected directory. Of course, I could save the last selected directory in the registry :( but I am looking for a better solution.
SaveFileDialog dialog = new SaveFileDialog();
//??? dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
dialog.ShowDialog();
任何意见?
您需要设置RestoreDirectory以真
还有InitialDirectory属性。
You need to set the RestoreDirectory
to true
as well as the InitialDirectory
property.