PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US

  • Operating mode in Windows Vista (and later)
  • Procedure that is using each copied file (syntax 2 only)
  • Values returned by the procedure (Syntax 2)
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
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.
Java False if a single file is not copied.
<Path of Directory to Copy>: Character string (with quotes)
Name and full (or relative) path of the directory to copy (up to 260 characters). A UNC path can be used. The wildcard characters (*,?) are allowed in the name of the file. This directory name may (or may not) end with "\".
Versions 15 and later
WindowsLinux This parameter can be in Ansi or Unicode format.
New in version 15
WindowsLinux This parameter can be in Ansi or Unicode format.
WindowsLinux This parameter can be in Ansi or Unicode format.
Java The wildcard characters (*,?) are not allowed in the file name.
<Path of Destination Directory>: Character string (with quotes)
Name and full (or relative) path of the 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
WindowsLinux This parameter can be in Ansi or Unicode format.
New in version 15
WindowsLinux This parameter can be in Ansi or Unicode format.
WindowsLinux This parameter can be in Ansi or Unicode format.
<Copy Indicator>: Optional constant (or combination of constants)
Type of copy to perform:
frConfirmCopy a directory and ask for confirmation before overwriting a directory with the same name.
WEBDEV - Server codePHP This constant is not available.
frProgressA progress window is displayed.
WEBDEV - Server codeJavaPHP This constant is not available.
frRecursiveThe sub-directories are processed.
<Copy Indicator> is empty by default. None of these options is selected.
Versions 19 and later
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)

Copying a directory by handling each copied file Hide the details

<Result> = fCopyDir(<Path of Directory to Copy> , <Path of Destination Directory> , <Procedure Name> [, <Pointer> [, <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 the directory to copy (up to 260 characters). A UNC path can be used. The wildcard characters (*,?) are allowed in the name of the file. This directory name may (or may not) end with "\".
WindowsLinux This parameter can be in Ansi or Unicode format.
<Path of Destination Directory>: Character string (with quotes)
Name and full (or relative) path of the 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.
WindowsLinux This parameter can be in Ansi or Unicode format.
<Procedure Name>: Character string (with or without quotes)
Name of WLanguage procedure ("callback" procedure) that will be called for each copied file. This procedure is used to handle the current file.
This procedure has the following format:
PROCEDURE <Procedure Name> (<Path of File to Copy>,
<Path of Destination File>, <Change>, <Procedure Pointer>)

The parameters of this procedure are optional.
There is no need to pass parameters to this procedure. Indeed, these parameters are automatically filled whenever a file is processed.
<Pointer>: Optional integer
Pointer passed to the <Procedure Name> procedure.
<Copy Indicator>: Optional constant
Type of copy to perform:
frRecursiveThe sub-directories are processed.
<Copy Indicator> is empty by default: the process is not recursive.
New in version 19
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)

Copying a directory by handling each copied file Hide the details

<Result> = fCopyDir(<Path of Directory to Copy> , <Path of Destination Directory> , <Procedure Name> [, <Pointer> [, <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 the directory to copy (up to 260 characters). A UNC path can be used. The wildcard characters (*,?) are allowed in the name of the file. This directory name may (or may not) end with "\".
WindowsLinux This parameter can be in Ansi or Unicode format.
<Path of Destination Directory>: Character string (with quotes)
Name and full (or relative) path of the 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.
WindowsLinux This parameter can be in Ansi or Unicode format.
<Procedure Name>: Character string (with or without quotes)
Name of WLanguage procedure ("callback" procedure) that will be called for each copied file. This procedure is used to handle the current file.
This procedure has the following format:
PROCEDURE <Procedure Name> (<Path of File to Copy>,
<Path of Destination File>, <Change>, <Procedure Pointer>)

The parameters of this procedure are optional.
There is no need to pass parameters to this procedure. Indeed, these parameters are automatically filled whenever a file is processed.
<Pointer>: Optional integer
Pointer passed to the <Procedure Name> procedure.
<Copy Indicator>: Optional constant
Type of copy to perform:
frRecursiveThe sub-directories are processed.
<Copy Indicator> is empty by default: the process is not recursive.
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)

Copying a directory by handling each copied file Hide the details

<Result> = fCopyDir(<Path of Directory to Copy> , <Path of Destination Directory> , <Procedure Name> [, <Pointer> [, <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 the directory to copy (up to 260 characters). A UNC path can be used. The wildcard characters (*,?) are allowed in the name of the file. This directory name may (or may not) end with "\".
WindowsLinux This parameter can be in Ansi or Unicode format.
<Path of Destination Directory>: Character string (with quotes)
Name and full (or relative) path of the 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.
WindowsLinux This parameter can be in Ansi or Unicode format.
<Procedure Name>: Character string (with or without quotes)
Name of WLanguage procedure ("callback" procedure) that will be called for each copied file. This procedure is used to handle the current file.
This procedure has the following format:
PROCEDURE <Procedure Name> (<Path of File to Copy>,
<Path of Destination File>, <Change>, <Procedure Pointer>)

The parameters of this procedure are optional.
There is no need to pass parameters to this procedure. Indeed, these parameters are automatically filled whenever a file is processed.
<Pointer>: Optional integer
Pointer passed to the <Procedure Name> procedure.
<Copy Indicator>: Optional constant
Type of copy to perform:
frRecursiveThe sub-directories are processed.
<Copy Indicator> is empty by default: the process is not recursive.
Remarks
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)

Operating mode in Windows Vista (and later)

If this function does not operate properly in Windows Vista (and later), check whether the file used is not found in one of the system directories (Windows directory or "Program Files" directory).
Indeed, in Windows Vista (and later), with the UAC mechanism (User Account Control) enabled, you must have the administrator privileges to handle and/or modify the files found in the system directories (Windows directory or "Program Files" directory).
Programming tip: To handle and/or modify the files without having administrator privileges, you should:
  • avoid writing into the Windows directory or into the "Program Files" directory,
  • use the system directory corresponding to the application (returned by SysDir associated with the srCommonAppData constant).
Note: In Windows Vista (and later), the virtualization mechanism is used to make the applications compatible with Vista. If the file is created in a system directory without having sufficient rights, this file will actually be created in another directory (C:\Users\<LOGIN>AppData\Local\VirtualStore\Windows\). In this case, the file cannot be shared between several applications.
Versions 19 and later

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:
  1. Create a global procedure (from the code editor: on the "Code" pane, in the "Procedures" group, expand "New" and select "New global procedure").
  2. Fill the declaration of the procedure 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 sub-directory 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 1flFirstFile
      Dir\File nflFile
      Dir\SubDir 1\File 1flChangeDir
      Dir\SubDir 1\File mflFile
      Dir\SubDir 2\File 1flChangeDir
      Dir\SubDir 2\File xflFile
  • <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>, the value of <Procedure Pointer> must be assigned to the value of <Pointer> in the procedure by Transfer.
Note: 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 19

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:
  1. Create a global procedure (from the code editor: on the "Code" pane, in the "Procedures" group, expand "New" and select "New global procedure").
  2. Fill the declaration of the procedure 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 sub-directory 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 1flFirstFile
      Dir\File nflFile
      Dir\SubDir 1\File 1flChangeDir
      Dir\SubDir 1\File mflFile
      Dir\SubDir 2\File 1flChangeDir
      Dir\SubDir 2\File xflFile
  • <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>, the value of <Procedure Pointer> must be assigned to the value of <Pointer> in the procedure by Transfer.
Note: 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:
  1. Create a global procedure (from the code editor: on the "Code" pane, in the "Procedures" group, expand "New" and select "New global procedure").
  2. Fill the declaration of the procedure 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 sub-directory 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 1flFirstFile
      Dir\File nflFile
      Dir\SubDir 1\File 1flChangeDir
      Dir\SubDir 1\File mflFile
      Dir\SubDir 2\File 1flChangeDir
      Dir\SubDir 2\File xflFile
  • <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>, the value of <Procedure Pointer> must be assigned to the value of <Pointer> in the procedure by Transfer.
Note: 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 later

Values returned by the procedure (Syntax 2)

The <Procedure Name> procedure must return one of the following values:
fcStopUsed to stop the copy permanently.
fcCopyUsed to continue the copy.
fcIgnoreUsed 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 the 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 while the current file was not copied.
New in version 19

Values returned by the procedure (Syntax 2)

The <Procedure Name> procedure must return one of the following values:
fcStopUsed to stop the copy permanently.
fcCopyUsed to continue the copy.
fcIgnoreUsed 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 the 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 while the current file was not copied.

Values returned by the procedure (Syntax 2)

The <Procedure Name> procedure must return one of the following values:
fcStopUsed to stop the copy permanently.
fcCopyUsed to continue the copy.
fcIgnoreUsed 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 the 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 while the current file was not copied.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230std.dll
Linux wd230std.so
Java wd230java.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment