OpenFileDialog and ApplicationSettings (FileName)

  • Thread starter Thread starter eBob.com
  • Start date Start date
E

eBob.com

In a very simple application I found that if I setup ApplicationSettings to
remember FileName, InitialDirectory, FileFilter and FileFilterIndex,
InitialDirectory seemed to be the only thing which was remembered across
invocations.

I just coded the most simple program I could imagine and setup the
OpenFileDialog ApplicationSettings to remember only FileName and
InitialDirectory. Again InitialDirectory is remembered across invocations
of the program but FileName is not.

My searches have not found anyone else reporting this problem. I am using
NET 3.5 on a Vista x64 system.

Thanks for any comments or insights. Bob
 
High,

Maybe a stupid question, but why do you want to use an openFileDialog when
you know the filename?

Cor
 
Did you save the settings (the MS documentation varies re whether or not you
need to explicitly save them).
 
Uh? Just because the filename variable has a current value does not mean
that the user is going to choose to open that file. The user might select a
different file. That's what the Open File dialog is for. It allows the
user to select the default filename as the file to open, or to choose a
different one.
 
Thanks,

Bob

James Hahn said:
Uh? Just because the filename variable has a current value does not mean
that the user is going to choose to open that file. The user might select
a different file. That's what the Open File dialog is for. It allows the
user to select the default filename as the file to open, or to choose a
different one.
 
Hi James,

Thanks for your interest.

No, I do nothing explicitly to save the settings. In my (limited)
experience with application settings that is not necessary. In this
particular case the directory is saved and restored by something, the
framework I suppose, but for some reason the filename is not.

Thanks, Bob
 
I would recommend saving the settings in the form closing event, if only to
see if it makes any difference.

Are you binding the properties or setting them manually?

If you set the default values of those properties to something other than
null in the settings designer, then synchronise, you should be able to see
the defaults in the dialog object by the end of the form load event. That
would at least confirm that the load is operating OK. Then you can check
the settings values in the form closing, just before you save.

It is also possible to trace the settings update through the My class code,
to detect when they are getting updated.
 
Back
Top