Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checking if file exists.

Status
Not open for further replies.

rache1

Programmer
Mar 20, 2001
9
TW
Hi.

I have this application that loads the Common Dialog Box whenever a user clicks on Save Button. I need to check if the filename the user entered is existing and prompts the user if the file is to be overwritten.

I have set the common dialog flag as :
CommonDialog1.Flags = cdlOFNOverwritePrompt
CommonDialog1.ShowSave

this will automatic prompts the user in form of a msgbox if the file is to be overwritten, but how do I check what the user has clicked i.e. Yes or No on the msgbox, is there a way to detect?

Thanks for the help.

 
I don't know if this is what you're looking for, but I usually have something like:
if CommonDialog1.Filename<>&quot;&quot; then exit sub 'user cancels
if dir(CommonDialog1.filename)<>&quot;&quot; then kill CommonDialog1.filename 'the user has click 'yes' to overwrite promt

If the user selects 'cancel' the CommonDialog will return empty and the file will not be deleted. (When the user selects 'yes' or 'no' to the overwrite promt (s)he will return to the CommonDialog and has to selct 'ok' or 'cancel'.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top