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
272 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

634 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