Open File Dialog - Prevent change of dir & file renaming?

K

kiln

I'm working with the CommonDlg class code found in the Access 2002
Desktop Developer's Handbook. Ideally I'd like to keep the user from
browsing away from the intitial dir; and prevent file name changes. I
don't see a way that this (versatile) class can handle this. Does anyone
know of a good alternative?
 
K

kiln

That's basically the code I'm working with; there is no facility to
prevent file rename or dir change.
 
D

Douglas J. Steele

I'm not sure it's possible.

Randy Birch has a good explanation of what each of the flags can do at
http://vbnet.mvps.org/code/comdlg/filedlgsoverview.htm There doesn't appear
to be a flag to prevent file name changes, and despite its name, I don't
think the OFN_NOCHANGEDIR prevents browsing in other folders (it simply
ensures that the current directory, as returned by CD or CurDir, doesn't
change if the user changed the directory while searching for files).
 
K

kiln

I'm not sure it's possible.

Randy Birch has a good explanation of what each of the flags can do at
http://vbnet.mvps.org/code/comdlg/filedlgsoverview.htm There doesn't appear
to be a flag to prevent file name changes, and despite its name, I don't
think the OFN_NOCHANGEDIR prevents browsing in other folders (it simply
ensures that the current directory, as returned by CD or CurDir, doesn't
change if the user changed the directory while searching for files).
Right, that's how I understood that flag too.

If the need seems pressing I'll put together a custom dir browse dialog;
the dialog is an entry point into a set of managed folders, I don't want
them altering file names or moving things by hand.
 
L

Larry Linson

If the names are known, it should be easy to put code after the call to
reject a change (and display a MsgBox to the user). All the Common Dialog
does is return the path and name as a text string. It is up to you what to
do with it.

Creating a "custom dir browse dialog" is not necessary.

Larry Linson
Microsoft Access MVP
 
K

kiln

Not really, in this case your advice is wrong.

Say the user opens the dialog to a dir that has 12 files in it. They
rename 10 of the files, then open one. Yes I could write a mess of code
to track the original files names, and then detect changes and then tell
the user and then revert the file names, but that's harder than writing
a file dialog that disallows the changes in the first place. In
addition, they could nav to other folders and mod file names there too.
The task of file rename prevention becomes too difficult...the idea here
is that the users should be prevented from modding any of the exposed
file names, as those are controlled programmatically and form a part of
an extended information system.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top