获取的FileOpen对话框中的最后一个打开的文件 [英] Getting the last opened file in fileopen dialog box

查看:177
本文介绍了获取的FileOpen对话框中的最后一个打开的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在的FileOpen或的FileSave DialogBox的时候我给他们打电话,他们会自动转到最后打开的路径。出现这种情况,即使我闭上我的应用程序并打开它。可是如何才能让这个路径/文件名的文本框或变量?

In FileOpen or FileSave dialogbox when I call them, they automatically go to the last opened path. This happens even if I close my application and open it. But how to get that path/file name to a textbox or variable?

推荐答案

我有一个类似的问题玉萍,这去如下。我在Visual Basic 2008速成版在Vista SP2业务发展。

I am having a similar problem to Vicky, which goes as follows. I am developing in Visual Basic 2008 Express Edition under Vista Business SP2.

我有一个OpenFileDialog和SaveFileDialog的应用程序。当我打电话的OpenFileDialog第一次运行的应用程序,它默认为从该应用程序最后打开的目录/保存的文件。然而,这个目录是不是Environment.CurrentDirectory,这是设置为C:\Users\Brian\Documents\Visual工作室2008\Projects\IFPM Analysis\IFPM Analysis\bin\Debug并且不被任一的OpenFileDialog或SaveFileDialog改变

I have an application with an OpenFileDialog and a SaveFileDialog. When I call the OpenFileDialog on first running the application, it defaults to the directory from which the Application last opened/saved a file. However, this directory IS NOT "Environment.CurrentDirectory" which is set to "C:\Users\Brian\Documents\Visual Studio 2008\Projects\IFPM Analysis\IFPM Analysis\bin\Debug" and is not changed by either the OpenFileDialog or SaveFileDialog.

稍后在应用程序,我打电话SaveFileDialog,与最初的目录属性(.InitialDirectory)中的代码集在默认目录。当我随后致电打开文件对话框,默认由SaveFileDialog使用的目录。所有的时间中,Environment.CurrentDirectory的值保持不变。

Later on in the Application, I call the SaveFileDialog, with the initial directory property (.InitialDirectory) set in the code to a default directory. When I subsequently call the OpenFileDialog, it defaults to the directory used by the SaveFileDialog. All the time, the value of "Environment.CurrentDirectory" is unchanged.

所以,我的问题是,在这里的是,正在使用的的OpenFileDialog和SaveFileDialog作为目录存储在哪里?我认为它是值得做的基本的FileDialog类的,我知道的应用程序已经关闭并重新启动甚至后仍然存在。

So, my question is, where is the directory that is being used by the OpenFileDialog and SaveFileDialog being stored? I assume it is something to do with the underlying FileDialog class, and I know persists even after the Application has been closed and restarted.

理想我希望能够存储该目录从打开文件对话框的用户选择,并且重置我已经使用了SaveFileDialog后。虽然我可以在应用程序中使用的OpenFileDialog的InitialDirectory财产,这并不能帮助我,当我关闭应用程序并重新启动它。可悲的是,典型的用户操作是:

Ideally I want to be able to store the directory selected by the user from the OpenFileDialog and reset it after I have used the SaveFileDialog. While I can use the InitialDirectory property of the OpenFileDialog within the Application, this doesn't help me when I close the Application and restart it. Sadly, the typical user actions are:


  • 启动应用程序

  • 开启文件,打开文件对话框

  • 保存文件,SaveFileDialog

  • 将应用程序

  • start Application
  • open file with OpenFileDialog
  • save file with SaveFileDialog
  • leave Application

这手段当用户回来的应用,缺省目录是错误的之一。我知道我可以从保存的OpenFileDialog最后使用的目录在我自己的配置文件,这样它会持续在应用程序之外,但似乎有点傻当Windows为我提供了相同的功能,如果只有我知道去哪里找!

This means that when the user comes back to the Application, the default directory is the "wrong" one. I know that I can save the last used directory from the OpenFileDialog in my own configuration file so that it will persist outside of the Application, but that seems a little silly when Windows provides me with the same functionality, if only I knew where to look!

任何帮助感激地接受!

谢谢,
布赖恩。

Thanks, Brian.

这篇关于获取的FileOpen对话框中的最后一个打开的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆