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
233 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 62

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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 …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now