Well. the code itself works good, but not always.
This is the code which gives the problem:
AssignFile(fid1,filename1);
Reset(fid1);
if not IOresult=0 then
MessageDlg('Origin file not found!',mtInformation, [mbOK],0)
else
begin
AssignFile(fid2,filename2);
ReWrite(fid2);
if not IOresult=0 then
MessageDlg('Failed opening destination file!',mtInformation, [mbOK],0)
else
begin
while not Eof(fid1) do
begin
Read(fid1,C);
Write(fid2,C);
end;
CloseFile(fid2);
end;
end;
CloseFile(fid1);
[/size]
This should be an dummy way to copy a file.
Variables filename1 and filename2 are strings containing the file names, respectively, of the origin file and the destination file.
It is compiled properly, but the problem arise when I give a wrong origin file name.
In such a situation MessageDlg('Origin file not found!',...) should pop up.
If I run the *.exe from windows explorer or a dos shell, this happens as aspected, but if I run the program from the IDE, no popup is shown and the program crashes! :evil: