DirCopy function is used to copy a folder/ directory. It copies all the sub directories and files inside the source directory.
If the destination directory structure does not exist, it will be created. If a copied file already exist, the overwrite flag determines whether to overwrite the file or not. The existing files do not overwrite by default.
DirCopy function returns 1 for success and 0 if there is an error copying the directory. If the source directory does not exist, the function returns 0.
Example:
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
;Copy My Documents directory to <temp>\Backups\MyDocs and get the status.
$bStatus = DirCopy(@MyDocumentsDir, @TempDir & "\Backups\MyDocs", $FC_OVERWRITE)
;Display status message.
If $bStatus Then
MsgBox($MB_ICONINFORMATION, "Status", "Directory copied successfully.")
Else
MsgBox($MB_ICONERROR, "Status", "Error copying the directory.")
EndIf
#include <MsgBoxConstants.au3>
;Copy My Documents directory to <temp>\Backups\MyDocs and get the status.
$bStatus = DirCopy(@MyDocumentsDir, @TempDir & "\Backups\MyDocs", $FC_OVERWRITE)
;Display status message.
If $bStatus Then
MsgBox($MB_ICONINFORMATION, "Status", "Directory copied successfully.")
Else
MsgBox($MB_ICONERROR, "Status", "Error copying the directory.")
EndIf
Related Posts
- AutoIt - How to Create a Folder
- AutoIt - How to Move a Folder
- AutoIt - How to Rename a Folder
- AutoIt - How to Delete a Folder
Interesting? Share and Let Others Know.
Post a Comment