Moves files to another directory


      FileMove(<cSourceFile>, <cTargetFile>) --> <nResultCode>


<cSourceFile> : Designates the name and the path of the source file.

<cTargetFile> : Designates the name and the path of the target file.


<nResultCode> : a value of 0 when the file can be moved; otherwise, an error code is returned. The codes are defined below:

          FileMove() Return Codes
          Code    Symb. constants        Definition
           0      NO_DISK_ERR            No errors
          -2      ER_FILE_NOT_FOUND      File not found
          -3      ER_PATH_NOT_FOUND      Access path not found
          -5      ER_ACCESS_DENIED       Access denied (e.g., network)
          -17     ER_DIFFERENT_DEVICE    Target file not on same drive


If a file is to be copied within a drive and then deleted it from the original position, it is quicker to move the file. FileMove() makes this possible. The directory entries are also changed, which is much quicker than copying and deleting.


. You can use drive designators and access paths in <cSourceFile> and <cTargetFile> file names. Wildcards are not permitted.

. You can only move a file within a drive. If the target directory already contains a file with the same name as the one from <cSourceFile>, the move is not completed. In this case, FileMove() returns a value of -5. The only option available in this situation, is to delete the file in the target directory.


      Move a file from "\OLD" to "\NEW":

      IF FileMove("\OLD\CUST.DBF", "\NEW\CUST.DBF") = 0
         ? "The file is now in the \NEW directory"



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.