guides:programming:programmers_reference_manual:copydir_method_filesystem

COPYDIR method (Filesystem)

Copies a directory and subdirectories to a specified location, optionally showing a progress information and allowing an Undo operation.

SuccessFlag = Exec_Method( "FILESYSTEM",  
                           "COPYDIR",     
                           DirFrom,       
                           DirTo,         
                           CopyDirOptions )
NameRequiredDescription
DirFromYesFully qualified path of the directory to copy.
DirToYesFully qualified path of the location to copy the directory to. Wildcard characters are not supported in this argument.
CopyDirOptionsNoContains an @Fm-delimited dynamic array of options that control the behavior of the copy operation:



<1> Allow undo

<2> Allow UI

<3> Parent window ID

<4> Progress dialog title

<5> Allow confirmations

TRUE$ if the copy was performed successfully, or FALSE$ if an error occurred. If the case of the latter event the FILEOPRESULT property may be used to obtain more details regarding the failure.

The CopyDirOptions argument is composed of five fields which control the behavior of the copy operation – each field is described fully below:

FieldNameDescription
<1>Allow undoIf TRUE$ then save Undo information. Defaults to FALSE$.
<2>Allow UIIf TRUE$ then allow any appropriate dialogs to be displayed such as progress and error information. Defaults to FALSE$.
<3>Parent window IDSpecifies the name of a WINDOW object to use as the parent for any dialogs displayed during the copy operation.
<4>Progress dialog titleText to display in the progress dialog during the copy operation.
<5>Allow confirmationsIf TRUE$ then allow the user to respond to any confirmation dialogs presented during the copy operation. Defaults to FALSE$.

The COPYDIR method is basically a wrapper around the SHFileOperation Windows API function, so it is worth examining at the documentation for this on the MSDN website to get a better idea of the capabilities of this method.

You should use fully qualified path names with this method. Using it with relative path names is not thread safe.

Equated constants for use with the COPYDIR method can be found in the PS_FILESYSTEM_EQUATES insert record.

 
// Use the FILESYSTEM COPYDIR method to copy an entire folder and it's

   // contents to another location, showing any progress information, but not

   // allowing the user to override any conflicts.

   

   $Insert PS_FileSystem_Equates

   $Insert Logical

   

   DirFrom     = "c:\my_data\aug_2017"

   DirTo       = "c:\backup\backup_data"

   

   CopyOptions = ""  

   CopyOptions<PS_CPD_ALLOWUNDO$>     = TRUE$  ; // Save Undo info

   CopyOptions<PS_CPD_ALLOWUI$>       = TRUE$  ; // Show dialogs

   CopyOptions<PS_CPD_PARENTWINDOW$>  = @Window

   CopyOptions<PS_CPD_PROGRESSTITLE$> = "Copying data to backup folder"

   CopyOptions<PS_CPD_ALLOWCONFIRM$>  = FALSE$

   

   If Exec_Method( "FILESYSTEM", "COPYDIR", DirFrom, DirTo, CopyOptions ) Then

      // Copied OK - data is now in:

      //

      //      "c:\backup\backup_data\aug_2017"

   End Else

      ErrorInfo = Get_Property( "FILESYSTEM", "FILEOPRESULT" )

      

      ErrorCode = ErrorInfo<PS_FOR_ERRORCODE$>

      ErrorText = ErrorInfo<PS_FOR_ERRORTEXT$>

      

      // Handle Error  ....

   End
 
 
 

FILOPRESULT property.

  • guides/programming/programmers_reference_manual/copydir_method_filesystem.txt
  • Last modified: 2023/10/25 10:49
  • by 127.0.0.1