I'm trying to verify and error trap the saving of a StringList to a file using SaveToFile, to ensure it has completed successfully, or tell me if it can't.
I couldn't seem to do something like:
so I tried the routine here:
and called it with this:
I ran the code once to create the file file.txt, then opened the file in notepad and then notepad++, and ran the routine again.
The routine ran error free each time, no report of the file in use, and the routine (which adds text to the lines) was successful each time, despite my having it open elsewhere.
Am I doing something wrong, or is there a better way?
Steve (Delphi 2007 & XP)
I couldn't seem to do something like:
Code:
if not StringList1.SaveToFile('file.txt') then action
so I tried the routine here:
and called it with this:
Code:
if IsFileInUse('file.txt') then
begin
PlaySound('SystemQuestion', 0, SND_ALIAS or SND_ASYNC);
ShowMessage('Could not save to disk');
end
else
StringList1.SaveToFile('file.txt');
I ran the code once to create the file file.txt, then opened the file in notepad and then notepad++, and ran the routine again.
The routine ran error free each time, no report of the file in use, and the routine (which adds text to the lines) was successful each time, despite my having it open elsewhere.
Am I doing something wrong, or is there a better way?
Steve (Delphi 2007 & XP)