Delphi overwrite existing file on save dialog

Posted by AfterImage on Stack Overflow See other posts from Stack Overflow or by AfterImage
Published on 2010-03-31T15:05:06Z Indexed on 2010/03/31 15:13 UTC
Read the original article Hit count: 459

Filed under:
|
|

Hello everyone,

I am using the TSaveDialog component to save a file from a button click. However, I am having trouble with saving on an existing file name. Generally, when you want to save over an existing file in Windows, a message box pops up asking you if you really want to overwrite the file. This is not the case with the TSaveDialog component and it will go ahead and write over the file without asking.

I was hoping there was a TSaveDialog function or event that I could use but I have not seen anything that looks like it handles this. So it could be that I simplely haven't found the correct method to use. If there is an event, I could use

if FileExists(saveDialog.FileName) then
  //and so forth

but the events TSaveDialog has are OnCanClose, OnClose, OnFolderChange, OnIncludeItem, OnSelectionChange, OnShow, OnTypeChange...

My question is, how do I pop up a message box to ask the user if they want to overwrite the existing file using the TSaveDialog component. Thanks.

© Stack Overflow or respective owner

Related posts about delphi

Related posts about delphi-7