Solved

How do you set memory for the OpenFileDialog so that it opens in the same directory as the last time you saved/opened a file?

Posted on 2006-06-19
2
259 Views
Last Modified: 2010-04-23
I was wondering how to set memory for the OpenFileDirectory or SaveFildirectory so that when a file dialog is opened, it opens in the same directory as the last time you used the open file dialog or the same directory as the last time you used the save dialog box.  Any takers?  It's worth 500 big points!  How would I code this in VB.NET For a Windows Form?
0
Comment
Question by:VBBRett
2 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 16934558
Before showing a dialog set it's InitialDirectory property to required value:

dlg.InitialDirectory = directory

When dialog is closed, get directory from it's FileName property:

directory = Path.GetDirectoryName(dlg.FileName)

Use directory for the next call to Open/Save dialog. If you want to keep initial directory persistent, keep it in the Registry or application settings.
0
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 16935280
Hi VBBRett;

I think this will work for you.

After creating the OpenFileDialog or the SaveFileDialog and before doing the ShowDialog methed do this:

OpenFileDialog
        Dim ofd As New OpenFileDialog
        ofd.RestoreDirectory = False
        ofd.ShowDialog()

Save File Dialog
        Dim sfd As New SaveFileDialog
        sfd.RestoreDirectory = False
        sfd.ShowDialog()

Fernando
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question