Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
283 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 64

Accepted Solution

by:
Fernando Soto earned 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

916 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