LATEST UPDATES
ShareHolder Finder v0.9.3 is now released!!! Check Product Page for more details.
✉ info@automationdevelopers.com

ITS ALL ABOUT AUTOMATION

Sunday, 9 October 2016

AutoIt - How to Copy a Folder


Author Post Date Sunday, 9 October 2016
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

Related Posts





Interesting? Share and Let Others Know.

Post a comment