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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Network CopyFile Errors 1

Status
Not open for further replies.

klaird

Programmer
Feb 6, 2009
1
US
I've been working on an app that gathers log files off of several remote machines.

In most cases using CopyFile() has returned the file or a usable Error code. However on occasion ERROR_FILE_NOT_FOUND is returned. In some instances this is correct, in others the error is not that the file wasn't found but that the network resource was not found. By mapping the drive manually the application is then able to gather the required logs.
The application does handle Error_Access_Denied, Error_logon_failure, Error_path_not_found, and Error_bad_netpath.

is there another method that would more accurately return error codes? Or a plausible explanation for why the wrong error code would be sent?
 
I would presume you're doing something like this?

Code:
var
    infile, outfile: string;
    gle: DWord;
  begin
    infile := 'DUMMY.TXT';
    outfile := 'DUMMY2.TXT';
    if CopyFile(PChar(infile), PChar(outfile), true) then
      MessageDlg('Copy successful', mtInformation, [mbOK], 0)
    else
      begin
        gle := GetLastError;
        MessageDlg('Error ' + IntToStr(gle) + ' : ' + SysErrorMessage(gle), mtInformation, [mbOK], 0);
      end;

And GetLastError tells you nothing specific and is returning what is seemingly wrong codes?

Measurement is not management.
 
I found it much easier to get good network connections to files by using the Shell versions of the combo, tree view and list view components. On the Samples pallet of D7.

Also look at IOResult.





Steve: N.M.N.F.
If something is popular, it must be wrong: Mark Twain
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top