Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error While using the CopyFile function

Hello I am using the CopyFile function in Delphi 5. But the file is not getting copied to destination. I am not able to see error also. What is the best way to know why CopyFile is failing?

if CopyFile(source, dest, false) then
  ShowMessage('Success')
else
  ShowMessage('Error');

I am getting displayed error always. :(

like image 898
Nalu Avatar asked Dec 09 '22 22:12

Nalu


1 Answers

If the function fails you can get extended error information, calling the GetLastError method or use the RaiseLastOSError method.

Check this sample

  try
    If copyFile(source , dest,false) then
     ShowMessage('Success')
    else
     RaiseLastOSError;
  except  on E: Exception do
     showMessage(Format('Error executing copyFile %s',[E.Message]));
  end;
like image 79
RRUZ Avatar answered Dec 14 '22 23:12

RRUZ