- Operating mode in Windows Vista (and later)
- Procedure that is using each copied file (syntax 2 only)
- Values returned by the procedure (Syntax 2)
fCopyDir (Function) In french: fRepCopie Copies the content of a directory and possibly the content of its sub-directories.
// Copy a directory Res = fCopyDir("C:\Directory\MyFiles", "D:\Documents\FileCopy", ... frConfirm + frProgress + frRecursive)
Versions 19 and later
// Copy a directory Res = fCopyDir("C:\Directory\MyFiles", "D:\Documents\FileCopy", FilterFile)
PROCÉDURE FilterFile(sSourcePath, sDestinationPath, flChange, nCustomParameter)
// Don't copy the temporary files IF fExtractPath(sSourcePath, fExtension) ~= ".tmp" RESULT fcIgnore ELSE RESULT fcCopy END
New in version 19
// Copy a directory Res = fCopyDir("C:\Directory\MyFiles", "D:\Documents\FileCopy", FilterFile)
PROCÉDURE FilterFile(sSourcePath, sDestinationPath, flChange, nCustomParameter)
// Don't copy the temporary files IF fExtractPath(sSourcePath, fExtension) ~= ".tmp" RESULT fcIgnore ELSE RESULT fcCopy END
// Copy a directory Res = fCopyDir("C:\Directory\MyFiles", "D:\Documents\FileCopy", FilterFile)
PROCÉDURE FilterFile(sSourcePath, sDestinationPath, flChange, nCustomParameter)
// Don't copy the temporary files IF fExtractPath(sSourcePath, fExtension) ~= ".tmp" RESULT fcIgnore ELSE RESULT fcCopy END
Syntax
Copying a directory Hide the details
<Result> = fCopyDir(<Path of directory to copy> , <Path of destination directory> [, <Copy indicator>])
<Result>: Boolean - True if the copy was performed,
- False otherwise. To find out the error details, use ErrorInfo associated with the errMessage constant.
<Path of directory to copy>: Character string (with quotes) Name and full (or relative) path of directory to copy (up to 260 characters). A UNC path can be used. Wildcard characters (*,?) are allowed in the file name. This directory name may (or may not) end with "\".
Versions 15 and later New in version 15 <Path of destination directory>: Character string (with quotes) Name and full (or relative) path of copied directory (up to 260 characters). A UNC path can be used. This directory name may (or may not) end with "\". This directory is automatically created if it does not exist.
Versions 15 and later New in version 15 <Copy indicator>: Optional constant (or combination of constants) Type of copy to perform: | | frConfirm | Copy a directory and ask for confirmation before overwriting a directory with the same name.
| frProgress | A progress window is displayed.
| frRecursive | Subdirectories are processed. | <Copy indicator> is empty by default. None of these options is selected. Versions 19 and later New in version 19Remarks Versions 19 and laterProcedure that is using each copied file (syntax 2 only) For each file found, fCopyDir automatically calls the <Procedure name> procedure. This procedure is a local or global procedure. To create this procedure: - Create a global procedure (from the code editor: on the "Code" pane, in the "Procedures" group, expand "New" and select "New global procedure").
- Fill the procedure declaration as follows:
PROCEDURE <Procedure name> (<Path of file to copy>, <Path of destination file>, <Change>, <Procedure pointer>)
- <Path of file to copy> is the path of the file to copy.
- <Path of destination file> is a character string containing the name of the destination file.
- <Change> is a constant set to:
- flFirstFile when the file is the first file copied into the <Source file> directory.
- flChangeDir when the file is the first file listed in a subdirectory of <Path of directory to copy> (which means that a change of directory occurred).
- flFile in all the other cases.
The different values that can be taken by <Change> are as follows:
| | Current file | <Change> |
---|
Dir\File 1 | flFirstFile | Dir\File n | flFile | Dir\SubDir 1\File 1 | flChangeDir | Dir\SubDir 1\File m | flFile | Dir\SubDir 2\File 1 | flChangeDir | Dir\SubDir 2\File x | flFile |
- <Procedure pointer> is an integer whose value is the one passed to the <Pointer> parameter of fCopyDir. If <Pointer> is not specified, <Pointer> is set to 0.
To retrieve the value of <Procedure pointer>, its value must be assigned to the value of <Pointer> in the procedure with Transfer. Remark: The parameters of this procedure are optional: you can for example only specify the path of the file to copy and the path of the destination file. New in version 19Procedure that is using each copied file (syntax 2 only) For each file found, fCopyDir automatically calls the <Procedure name> procedure. This procedure is a local or global procedure. To create this procedure: - Create a global procedure (from the code editor: on the "Code" pane, in the "Procedures" group, expand "New" and select "New global procedure").
- Fill the procedure declaration as follows:
PROCEDURE <Procedure name> (<Path of file to copy>, <Path of destination file>, <Change>, <Procedure pointer>)
- <Path of file to copy> is the path of the file to copy.
- <Path of destination file> is a character string containing the name of the destination file.
- <Change> is a constant set to:
- flFirstFile when the file is the first file copied into the <Source file> directory.
- flChangeDir when the file is the first file listed in a subdirectory of <Path of directory to copy> (which means that a change of directory occurred).
- flFile in all the other cases.
The different values that can be taken by <Change> are as follows:
| | Current file | <Change> |
---|
Dir\File 1 | flFirstFile | Dir\File n | flFile | Dir\SubDir 1\File 1 | flChangeDir | Dir\SubDir 1\File m | flFile | Dir\SubDir 2\File 1 | flChangeDir | Dir\SubDir 2\File x | flFile |
- <Procedure pointer> is an integer whose value is the one passed to the <Pointer> parameter of fCopyDir. If <Pointer> is not specified, <Pointer> is set to 0.
To retrieve the value of <Procedure pointer>, its value must be assigned to the value of <Pointer> in the procedure with Transfer. Remark: The parameters of this procedure are optional: you can for example only specify the path of the file to copy and the path of the destination file. Procedure that is using each copied file (syntax 2 only) For each file found, fCopyDir automatically calls the <Procedure name> procedure. This procedure is a local or global procedure. To create this procedure: - Create a global procedure (from the code editor: on the "Code" pane, in the "Procedures" group, expand "New" and select "New global procedure").
- Fill the procedure declaration as follows:
PROCEDURE <Procedure name> (<Path of file to copy>, <Path of destination file>, <Change>, <Procedure pointer>)
- <Path of file to copy> is the path of the file to copy.
- <Path of destination file> is a character string containing the name of the destination file.
- <Change> is a constant set to:
- flFirstFile when the file is the first file copied into the <Source file> directory.
- flChangeDir when the file is the first file listed in a subdirectory of <Path of directory to copy> (which means that a change of directory occurred).
- flFile in all the other cases.
The different values that can be taken by <Change> are as follows:
| | Current file | <Change> |
---|
Dir\File 1 | flFirstFile | Dir\File n | flFile | Dir\SubDir 1\File 1 | flChangeDir | Dir\SubDir 1\File m | flFile | Dir\SubDir 2\File 1 | flChangeDir | Dir\SubDir 2\File x | flFile |
- <Procedure pointer> is an integer whose value is the one passed to the <Pointer> parameter of fCopyDir. If <Pointer> is not specified, <Pointer> is set to 0.
To retrieve the value of <Procedure pointer>, its value must be assigned to the value of <Pointer> in the procedure with Transfer. Remark: The parameters of this procedure are optional: you can for example only specify the path of the file to copy and the path of the destination file. Versions 19 and laterValues returned by the procedure (Syntax 2) The <Procedure name> procedure must return one of the following values: | | fcStop | Used to stop the copy permanently. | fcCopy | Used to continue the copy. | fcIgnore | Used to ignore the copy of a file. | A WLanguage error occurs if the procedure does not return one of these values. Case 1. Full interruption of copy To force the interruption of copy, the <Procedure name> procedure must return the fcStop constant. Example: the "CopyProduct" procedure is automatically called by fCopyFile:
PROCÉDURE CopyProduct(PathSourceFile, PathDestinationFile) ... // Stop requested? Multitask(-1) IF KeyPressed(kpEscape) = True THEN Info("The copy will be stopped") RESULT fcStop END ... RESULT fcCopy
If the Esc key is pressed, fCopyDir returns the fcStop constant. In the other cases (to continue the browse), the <Procedure name> procedure returns the fcCopy constant. Case 2. Partial interruption of copy In order for the <Procedure name> procedure not to be run for a given file, the <Procedure name> procedure must return the fcIgnore constant. Example: The "FindProduct" procedure is automatically called by fCopyFile:
PROCÉDURE FindProduct(PathSourceFile, PathDestinationFile) ... // File to ignore IF StringEndsWith(PathSourceFile, "WrongFile.XLS") THEN RESULT fcIgnore END ... RESULT fcCopy
To avoid copying the "WrongFile.XLS" file, the procedure returns the fcIgnore constant. The <Procedure name> procedure is automatically called for the next copied file, without copying the current file. New in version 19Values returned by the procedure (Syntax 2) The <Procedure name> procedure must return one of the following values: | | fcStop | Used to stop the copy permanently. | fcCopy | Used to continue the copy. | fcIgnore | Used to ignore the copy of a file. | A WLanguage error occurs if the procedure does not return one of these values. Case 1. Full interruption of copy To force the interruption of copy, the <Procedure name> procedure must return the fcStop constant. Example: the "CopyProduct" procedure is automatically called by fCopyFile:
PROCÉDURE CopyProduct(PathSourceFile, PathDestinationFile) ... // Stop requested? Multitask(-1) IF KeyPressed(kpEscape) = True THEN Info("The copy will be stopped") RESULT fcStop END ... RESULT fcCopy
If the Esc key is pressed, fCopyDir returns the fcStop constant. In the other cases (to continue the browse), the <Procedure name> procedure returns the fcCopy constant. Case 2. Partial interruption of copy In order for the <Procedure name> procedure not to be run for a given file, the <Procedure name> procedure must return the fcIgnore constant. Example: The "FindProduct" procedure is automatically called by fCopyFile:
PROCÉDURE FindProduct(PathSourceFile, PathDestinationFile) ... // File to ignore IF StringEndsWith(PathSourceFile, "WrongFile.XLS") THEN RESULT fcIgnore END ... RESULT fcCopy
To avoid copying the "WrongFile.XLS" file, the procedure returns the fcIgnore constant. The <Procedure name> procedure is automatically called for the next copied file, without copying the current file. Values returned by the procedure (Syntax 2) The <Procedure name> procedure must return one of the following values: | | fcStop | Used to stop the copy permanently. | fcCopy | Used to continue the copy. | fcIgnore | Used to ignore the copy of a file. | A WLanguage error occurs if the procedure does not return one of these values. Case 1. Full interruption of copy To force the interruption of copy, the <Procedure name> procedure must return the fcStop constant. Example: the "CopyProduct" procedure is automatically called by fCopyFile:
PROCÉDURE CopyProduct(PathSourceFile, PathDestinationFile) ... // Stop requested? Multitask(-1) IF KeyPressed(kpEscape) = True THEN Info("The copy will be stopped") RESULT fcStop END ... RESULT fcCopy
If the Esc key is pressed, fCopyDir returns the fcStop constant. In the other cases (to continue the browse), the <Procedure name> procedure returns the fcCopy constant. Case 2. Partial interruption of copy In order for the <Procedure name> procedure not to be run for a given file, the <Procedure name> procedure must return the fcIgnore constant. Example: The "FindProduct" procedure is automatically called by fCopyFile:
PROCÉDURE FindProduct(PathSourceFile, PathDestinationFile) ... // File to ignore IF StringEndsWith(PathSourceFile, "WrongFile.XLS") THEN RESULT fcIgnore END ... RESULT fcCopy
To avoid copying the "WrongFile.XLS" file, the procedure returns the fcIgnore constant. The <Procedure name> procedure is automatically called for the next copied file, without copying the current file.
This page is also available for…
|
|
|