RENAMEDIR Method (FileSystem)
Description
Renames a directory, optionally showing a progress information and allowing an Undo operation.
Syntax
SuccessFlag = Exec_Method( "FILESYSTEM", "RENAMEDIR", DirOldName, DirNewName, RenameDirOptions )
Parameters
Name | Required | Description |
---|---|---|
DirFrom | Yes | Fully qualified path of the directory to rename. |
DirTo | Yes | Fully qualified path of the new directory name. Wildcard characters are not supported in this argument. |
RenameDirOptions | No | Contains an @Fm-delimited dynamic array of options that control the behavior of the rename operation: <1> Allow undo <2> Allow UI <3> Parent window ID <4> Progress dialog title <5> Allow confirmations |
Returns
TRUE$ if the rename 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.
Remarks
The RenameDirOptions argument is composed of five fields which control the behavior of the rename operation – each field is described fully below:
Field | Name | Description |
---|---|---|
<1> | Allow undo | If TRUE$ then save Undo information. Defaults to FALSE$. |
<2> | Allow UI | If TRUE$ then allow any appropriate dialogs to be displayed such as progress and error information. Defaults to FALSE$. |
<3> | Parent window ID | Specifies the name of a WINDOW object to use as the parent for any dialogs displayed during the rename operation. |
<4> | Progress dialog title | Text to display in the progress dialog during the rename operation. |
<5> | Allow confirmations | If TRUE$ then allow the user to respond to any confirmation dialogs presented during the rename operation. Defaults to FALSE$. |
The RENAMEDIR 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 RENAMEDIR method can be found in the PS_FILESYSTEM_EQUATES insert record.
Example
// Use the FILESYSTEM RENAMEDIR method to rename an entire folder, 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:\my_data\aug_2017.bak" RenameOptions = "" RenameOptions<PS_RND_ALLOWUNDO$> = TRUE$ ; // Save Undo info RenameOptions<PS_RND_ALLOWUI$> = TRUE$ ; // Show dialogs RenameOptions<PS_RND_PARENTWINDOW$> = @Window RenameOptions<PS_RND_PROGRESSTITLE$> = "Renaming data to backup folder" RenameOptions<PS_RND_ALLOWCONFIRM$> = FALSE$ If Exec_Method( "FILESYSTEM", "RENAMEDIR", DirFrom, DirTo, RenameOptions ) Then // Renamed OK End Else ErrorInfo = Get_Property( "FILESYSTEM", "FILEOPRESULT" ) ErrorCode = ErrorInfo<PS_FOR_ERRORCODE$> ErrorText = ErrorInfo<PS_FOR_ERRORTEXT$> // Handle Error .... End
See Also
FILEOPRESULT property.