Link to home
Start Free TrialLog in
Avatar of Ramesh4u
Ramesh4u

asked on

Remebering the last saved directory path in a saveFileDialog


Hi all,

I am implementing a saveFileDialog in C# . First time when I choose a directory to save a file, I want to remember it so that for the second time , I do not have to start from my C: drive and go to the previously saved directory.

There should be a easy way to do, and your help on this is appreciated.

Ramesh
ASKER CERTIFIED SOLUTION
Avatar of Dmitry G
Dmitry G
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BBK_
BBK_

If you want to retain the selected directory name only till the application close, then better keep the value in a static variable,
If you want to keep this every time application opens, then better approch is to store the value in registry than in any XML or text file
I think you want to find out how to set the dialog programmaticly to a specified path, am I right?

Just before showing the dialog, set the dialog.filename property to your desired directory, like this:

dialog.FileName=@"C:\";
the "@" specifies not to interpret the \ as an escape sequence.

2 dreckgos

"then better approch is to store the value in registry than in any XML or text file"
No doubts. Give an example of code. Ramesh asked for an easy solution :)

2 Ramesh
If you want to save in the registry you may have a look at http://www.knowdotnet.com/articles/registrywrapper.html
anarki, I think you got the names wrong....
anarki, I think you got the names wrong....

 Dont forget Ramesh... save the directory in any way you want and then set the filename or filepath property!
My apologies, dreckgos!

The message was to BBK.