ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / External file functions
  • Error handling
  • Creating directories during the copy
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Copies one or more files (regardless of their attributes).
Syntax

Copying a file or a directory Hide the details

<Result> = fCopyFile(<Source file> , <Destination file or directory> [, <Copy indicator>])
<Result>: Boolean
  • True if the files have been copied,
  • False otherwise. To get more details on the error, use ErrorInfo with the errMessage constant.
<Source file>: Character string
File to copy (up to 260 characters). This parameter can correspond to:
  • a file name. This file will be automatically searched in the current directory (returned by fCurrentDir).
  • a file name with its full or relative path. A UNC path can be used.
Special cases according to the platforms:
  • AndroidAndroid Widget This parameter can correspond to a full path or a path relative to the current directory (returned by fCurrentDir). This parameter is case-sensitive.
    Reminder: In Android, the file system is read-only on the device and on the emulator. An application can only write to its installation directory or one of its subdirectories, as well as to the external memory (SDCard).
  • iPhone/iPadIOS WidgetMac Catalyst This parameter can correspond to a full path or a path relative to the current directory (returned by fCurrentDir). This parameter is case-sensitive.
    Reminder Under iPhone/iPad, on both the device and the emulator, the file system is read-only. An application can only write to its installation directory or one of its subdirectories.
Wildcard characters management (*,?): By default, wildcard characters are allowed in the file name..
Special case according to the platform:
    <Destination file or directory>: Character string
    Destination file and/or directory (up to 260 characters). This parameter can correspond to:
    • a file name. This file will be automatically created in the current directory (returned by fCurrentDir).
    • a file name with its full or relative path. A UNC path can be used.
    • a full or relative path, only for a copy with wildcard characters.
    If this parameter corresponds to a directory name, this name may (or may not) end with "\".
    Special cases according to the platforms:
    • AndroidAndroid Widget This parameter can correspond to a full path or a path relative to the current directory (returned by fCurrentDir). This parameter is case-sensitive.
      Reminder: In Android, the file system is read-only on the device and on the emulator. An application can only write to its installation directory or one of its subdirectories, as well as to the external memory (SDCard).
    • iPhone/iPadIOS WidgetMac Catalyst This parameter can correspond to a full path or a path relative to the current directory (returned by fCurrentDir). This parameter is case-sensitive.
      Reminder Under iPhone/iPad, on both the device and the emulator, the file system is read-only. An application can only write to its installation directory or one of its subdirectories.
    <Copy indicator>: Optional constant
    Type of copy:
    frConfirmCopy a file and ask for confirmation before overwriting a file with the same name.
    AndroidAndroid Widget This constant is not available.
    frProgressA progress window is displayed. If the file is small (a few bytes), the progress bar is not displayed.
    AndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst This constant is not available.
    frRecursiveRecursive copy of the files. The subdirectories and their files are taken into account.

    <Copy indicator> is empty by default. None of these options is selected.
    Remarks

    Error handling

    fCopyFile throws an error in the following cases:
    • the file to copy does not exist,
    • the file to copy is locked,
    • is invalid,
    • <Path of copied file> is an empty string,
    • <Path of file to copy> and <Path of copied file> are identical.

    Creating directories during the copy

    • If one of the directories of the destination path does not exist, it is automatically created.
    • AndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst If the source file corresponds to all the files found in a directory (for example, C:\Temp\*.*), the frRecursive constant must be used to create the subdirectories in the destination (and to copy their content).
    Note: To make directory copies, you can also use the fCopyDir function.
    Related Examples:
    Handling text files Unit examples (WINDEV): Handling text files
    [ + ] Handling "text" files with WINDEV:
    - Create a text file
    - Write into a text file
    - Read in a text file
    Handling text files Unit examples (WEBDEV): Handling text files
    [ + ] This example explains how to handle "non HFSQL" files with WEBDEV and it allows you to:
    - Create a text file
    - Write into a text file
    - Read in a text file
    Handling text files Unit examples (WINDEV Mobile): Handling text files
    [ + ] Handling external "text" files:
    - Create a text file
    - Write into a text file
    - Read in a text file
    Business / UI classification: Business Logic
    Component: wd300std.dll
    Minimum version required
    • Version 9
    This page is also available for…
    Comments
    EXEMPLO COPIAR ARQUIVO
    https://youtu.be/qws0RUJ0Eqs

    http://windevdesenvolvimento.blogspot.com.br/2018/05/dicas-1745-privada-windev-arquivos-29.html

    https://groups.google.com/d/forum/amarildowindev

    // EXEMPLO


    // COPIAR ARQUIVO

    // http://doc.windev.com/en-US/?3036004&name=fcopyfile_function

    Resultado is boolean = fCopyFile("C:\amarildo\ipi.txt", EDT_DIRETORIO+"ipi.txt")

    De matos
    29 May 2018
    Copiar Arquivo
    Copiar Arquivo

    Nessa aula vou mostrar como copiar um arquivo
    This lesson will show you how to copy a file
    Cette leçon va vous montrer comment copier un fichier

    n_resultado is int=fCopyFile("D:\amarildo\Copia\copiaarquivo.txt","D:\amarildo\Copia\novoarquivo.txt")


    n_resultado_F est entier=fCopieFichier("D:\amarildo\Copia\copiaarquivo.txt","D:\amarildo\Copia\novoarquivo.txt")

    //Blog com Video e exemplo
    http://windevdesenvolvimento.blogspot.com.br/2016/08/curso-windev-arquivos-008-arquivos.html
    https://www.youtube.com/watch?v=Q05zcTyXV1c
    De matos AMARILDO
    01 Sep. 2016

    Last update: 03/27/2025

    Send a report | Local help