PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US

  • Procedure that handles each listed file (syntax 2 only)
  • Full interruption of fListFile (syntax 2)
  • Partial interruption of fListFile (syntax 2)
  • Managing errors
  • Equivalence
  • Listing the sub-directories of a directory
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
Lists the files found in a directory and returns the list of files. The listed files are sought from the given directory.
Other use: For each file found, fListFile can automatically call a specific procedure written in WLanguage. This procedure is used to handle the current file. In this case, fListFile returns the number of listed files.
Note: In 64-bit Windows, the access to a system directory from a 32-bit executable can be performed in a directory that differs from the expected one. See Native 64-bit and native 32-bit for more details.
Versions 15 and later
Android This function is now available for the Android applications.
New in version 15
Android This function is now available for the Android applications.
Android This function is now available for the Android applications.
Versions 16 and later
Universal Windows 10 App This function is now available for the Windows Phone applications.
New in version 16
Universal Windows 10 App This function is now available for the Windows Phone applications.
Universal Windows 10 App This function is now available for the Windows Phone applications.
Versions 17 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for the iPhone/iPad applications.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Stored procedures This function is now available in the code of stored procedures.
New in version 18
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Stored procedures This function is now available in the code of stored procedures.
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Stored procedures This function is now available in the code of stored procedures.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
WINDEVReports and QueriesPHPAjaxUser code (UMC)
AFile, ResFileList are strings
// Lists the ".BMP" files found in "C:\MyDocuments".
// The browse is also performed in the sub-directories and it can be interrupted.
ResFileList = fListFile("\MyDocuments\*.BMP", frRecursive + frInterruptible)
// For each file found
FOR EACH STRING AFile OF ResFileList SEPARATED BY CR
// Add the file into TABLE_FileTable
TableAdd(TABLE_FileTable, AFile)
END
Windows Mobile
AFile, ResFileList are strings
// Lists the ".BMP" files found in "\MyDocuments".
// The browse is also performed in the sub-directories and it can be interrupted.
ResFileList = fListFile("\MyDocuments\*.BMP", frRecursive + frInterruptible)
// For each file found
FOR EACH STRING AFile OF ResFileList SEPARATED BY CR
// Add the file into TABLE_FileTable
TableAdd(TABLE_FileTable, AFile)
END
WINDEVWEBDEV - Server codeReports and QueriesJavaPHPAjaxUser code (UMC)
// Lists the ".BMP" files found in "C:\MyDocuments".
// The FileAttribute procedure returns the number of read-only files.
ResFileList = fListFile("C:\MyDocuments\*.BMP", "FileAttribute")
Windows Mobile
// Lists the ".BMP" files found in "\MyDocuments".
// The FileAttribute procedure returns the number of read-only files.
ResFileList = fListFile("\MyDocuments\*.BMP", "FileAttribute")
Syntax

Listing the files found in a directory Hide the details

<Result> = fListFile(<Path and Generic Name of Files> , <Options>)
<Result>: Character string
Full name of listed files, separated by CR characters (Carriage Return).

Caution: The function can return files whose short name corresponds to the filter used (while the long name does not correspond to this filter).
<Path and Generic Name of Files>: Character string (with quotes)
Path and generic name of files to list. The generic characters (* and?) are allowed. Special cases:
  • if the directory and the drive are not specified: the search path is built from the current drive and from the current directory for this drive.
  • if the drive is not specified while the directory is specified: the search path is built from the current drive and from the directory passed in parameter.
  • if the drive is specified while the directory is not specified, the search path is built from the specified drive and from the current directory for this drive.
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.
Windows Mobile Path and generic name of files to list. The generic characters (* and?) are allowed.
AndroidAndroid Widget This parameter can correspond to a full path or to a relative path in relation 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 has the rights to write into its setup directory or into one of its sub-directories, as well as onto the external memory (SDCard).
Versions 16 and later
Universal Windows 10 App In Windows Phone: The file path corresponds to a relative path in relation to the current directory. The current directory corresponds to the data directory of application.
Reminder: In Windows Phone, only the files found in the data directory associated with the application can be handled.
New in version 16
Universal Windows 10 App In Windows Phone: The file path corresponds to a relative path in relation to the current directory. The current directory corresponds to the data directory of application.
Reminder: In Windows Phone, only the files found in the data directory associated with the application can be handled.
Universal Windows 10 App In Windows Phone: The file path corresponds to a relative path in relation to the current directory. The current directory corresponds to the data directory of application.
Reminder: In Windows Phone, only the files found in the data directory associated with the application can be handled.
Versions 17 and later
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: On iPhone/iPad, an application has the rights to write into its setup directory or into one of its sub-directories.
New in version 17
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: On iPhone/iPad, an application has the rights to write into its setup directory or into one of its sub-directories.
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: On iPhone/iPad, an application has the rights to write into its setup directory or into one of its sub-directories.
<Options>: Combination of Integer constants
Option used to define the information returned as well as the type of browse performed for the directory files:
PHP This parameter is ignored.
Versions 15 and later
fPathUNICODE
New in version 15
fPathUNICODE
fPathUNICODE
<Result> will be a string in Unicode format.
Windows Mobile This constant is ignored because <Result> is always a Unicode string.
Versions 16 and later
Universal Windows 10 App This constant is ignored in Windows Phone.
New in version 16
Universal Windows 10 App This constant is ignored in Windows Phone.
Universal Windows 10 App This constant is ignored in Windows Phone.
fdFullInformationEach line (separated by carriage return - CR) contains the following information:

<Full File Name> + TAB + <Size in Bytes> + TAB + <Date of Last Modification> + TAB + <File Attributes>

The date is in YYYYMMDDHHMMSS format. The attributes are identical to the ones returned by fAttribute.
Versions 16 and later
Universal Windows 10 App This constant is ignored in Windows Phone.
New in version 16
Universal Windows 10 App This constant is ignored in Windows Phone.
Universal Windows 10 App This constant is ignored in Windows Phone.
fdInterruptibleThe browse can be interrupted by pressing the ESC key. The function will return the name of the listed files until the interruption.
WEBDEV - Server codeLinuxWindows MobileUniversal Windows 10 App This constant has no effect in Windows Phone and Windows Store apps.
frNotRecursiveThe browse is a non-recursive browse. The sub-directories are ignored.
frRecursive
(Default value)
The browse is a recursive browse. The sub-directories are automatically taken into account.
frNoHiddenFileIf the frFullInformation constant is used, the hidden files are not listed (attribute = "H").
Versions 16 and later
Universal Windows 10 App This constant is ignored in Windows Phone.
New in version 16
Universal Windows 10 App This constant is ignored in Windows Phone.
Universal Windows 10 App This constant is ignored in Windows Phone.
frNoHiddenDirectoryIf the frFullInformation constant is used, the hidden directories are not listed (attribute = "H").
Versions 16 and later
Universal Windows 10 App This constant is ignored in Windows Phone.
New in version 16
Universal Windows 10 App This constant is ignored in Windows Phone.
Universal Windows 10 App This constant is ignored in Windows Phone.
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadWindows MobileJavaPHPAjaxUser code (UMC)

Listing the files found in a directory by calling a procedure for each file Hide the details

<Result> = fListFile(<Path and Generic Name of Files> , <Procedure Name> [, <Pointer> [, <Options>]])
<Result>: Integer
Number of listed files.
<Path and Generic Name of Files>: Character string (with quotes)
Path and generic name of files to list. The generic characters (* and?) are allowed. Special cases:
  • if the directory and the drive are not specified: the search path is built from the current drive and from the current directory for this drive.
  • if the drive is not specified while the directory is specified: the search path is built from the current drive and from the directory passed in parameter.
  • if the drive is specified while the directory is not specified, the search path is built from the specified drive and from the current directory for this drive.
Windows Mobile Path and generic name of files to list. The generic characters (* and?) are allowed.
AndroidAndroid Widget This parameter can correspond to a full path or to a relative path in relation 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 has the rights to write into its setup directory or into one of its sub-directories, as well as onto the external memory (SDCard).
Versions 17 and later
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: On iPhone/iPad, an application has the rights to write into its setup directory or into one of its sub-directories.
New in version 17
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: On iPhone/iPad, an application has the rights to write into its setup directory or into one of its sub-directories.
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: On iPhone/iPad, an application has the rights to write into its setup directory or into one of its sub-directories.
<Procedure Name>: Character string (with or without quotes)
Name of WLanguage procedure ("callback" procedure) that will be called for each listed file. This procedure is used to handle the current file.
This procedure has the following format:
PROCEDURE <Procedure Name> (<Path>, <File Name>,
<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.
PHP The name of the procedure must correspond to a character string in quotes.
<Pointer>: Optional integer
Pointer passed to the <Procedure Name> procedure.
PHP Parameter passed to the function. This parameter is not necessarily an integer (it can be a string, ...).
<Options>: Optional Integer constant (or combination of constants)
Type of browse performed for the directory files:
Versions 15 and later
fPathUNICODE
New in version 15
fPathUNICODE
fPathUNICODE
<Result> will be a string in Unicode format.
Windows Mobile This constant is ignored because <Result> is always a Unicode string.
fdInterruptibleThe browse can be interrupted by pressing the ESC key.
WEBDEV - Server codeLinuxWindows Mobile This constant has no effect.
frNotRecursiveThe browse is a non-recursive browse. The sub-directories are ignored.
frRecursive
(Default value)
The browse is a recursive browse. The sub-directories are automatically taken into account.
PHP This parameter is ignored. The browse is a non-recursive browse and it cannot be interrupted.
Remarks

Procedure that handles each listed file (syntax 2 only)

For each file found, fListFile automatically calls the <Procedure Name> procedure. This procedure is a local or global procedure.
To create this procedure:
  1. Create a global procedure ("Insert .. New global procedure" in the code editor).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>, <File Name>,
<Change>, <Procedure Pointer>)
  • <Path> is the path of file used (it always ends with a "\" character ; for example, "C:\WINDEV\").
  • <File Name> is a character string containing the name of file found.
  • <Change> is a constant set to:
    • flFirstFile when the file is the first file listed in <Path>,
    • flChangeDir when the file is the first file listed in a sub-directory of <Path> (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 fListFile. 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 (see the detailed example at the top of the page).
Note: The parameters of this procedure are optional: you have the ability to specify the name and the path for example.

Full interruption of fListFile (syntax 2)

fListFile cannot be interrupted as long as all the files have not been browsed.
To force the interruption of the browse, use the following code line in the <Procedure Name> procedure:
RESULT False
For example, the "FindProduct" procedure is automatically called by fListFile:
PROCÉDURE FindProduct(Path, FileName)
...
// Stop requested?
Multitask(-1)
IF KeyPressed(kpEscape) = True THEN
Info("The search will be stopped")
RESULT False
END
...
RESULT True
In this case, fListFile returns the number of files browsed until the call to "Result False".
In any other case (to continue the browse), <Procedure Name> MUST return True.
An error is generated if <Procedure Name> returns no value (neither True nor False).
PHP No error is generated if the procedure returns no value.

Partial interruption of fListFile (syntax 2)

In order for the <Procedure Name> procedure not to be run for a given file, use the following code line:
RESULT True
For example, the "FindProduct" procedure is automatically called by fListFile:
PROCÉDURE FindProduct(Path, FileName)
...
// File to ignore
IF FileName = "WrongFile.XLS" THEN
RESULT True
END
...
RESULT True
In this case, fListFile automatically calls the <Procedure Name> procedure for the next listed file.
An error is generated if <Procedure Name> returns no value (neither True nor False).
PHP No error is generated if the procedure returns no value.

Managing errors

Caution: fListFile returns no error code. To find out whether an error was generated by this function, use ErrorInfo associated with the errMessage constant.
Windows Mobile

Equivalence

The operating mode of fListFile is equivalent to the operating mode of ceListFile.
The only difference is:
  • fListFile is using a directory found on Pocket PC from a WINDEV Mobile application.
  • ceListFile is using a directory found on Pocket PC from a WINDEV application.
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadWindows MobileJavaAjaxUser code (UMC)

Listing the sub-directories of a directory

To list the sub-directories of a directory, use fListDirectory.
Tip: fListFile can also be used to list the sub-directories of a directory.
Example:
fListFile("c:\temp\anim\.", proc)
// Don't forget the '.' at the end of string to identify the directories
PROCÉDURE proc(Dir, file, nChange, ptr)
Trace(Dir)
Related Examples:
The fListFile function Unit examples (WINDEV): The fListFile function
[ + ] Using fListFile and its syntax that directly returns the list of files/directories found in string format.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230std.dll
Windows Mobile wp230std.dll
Java wd230java.jar
Linux wd230std.so
Android wd230android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
EXEMPLO
https://youtu.be/1-Rhy8T5g-M

http://windevdesenvolvimento.blogspot.com/2018/04/dicas-1741-publica-windev-arquivos-25.html

https://groups.google.com/d/forum/amarildowindev
http://windevdesenvolvimento.blogspot.com/2018/01/inscricao-para-grupo-privado-amarildo.html
http://windevdesenvolvimento.blogspot.com.br/2017/07/menu-blog.html

// EXEMPLO

TableDeleteAll(TABLE_LISTA_ARQUIVOS)
s_arquivos_todos is string=fListFile(EDT_DIRETORIO+"*.*")
FOR EACH STRING s_arquivo_individual OF s_arquivos_todos SEPARATED BY CR
Message(s_arquivo_individual)
s_nome_arquivo is string=fExtractPath(s_arquivo_individual,fFileName+fExtension)
s_tamanho_arquivo is string=fSize(EDT_DIRETORIO+s_nome_arquivo)
dS_data_arquivo is Date=fDate(EDT_DIRETORIO+s_nome_arquivo)
hS_hora_arquivo is Time=fTime(EDT_DIRETORIO+s_nome_arquivo)
TableAddLine(TABLE_LISTA_ARQUIVOS,s_nome_arquivo,s_tamanho_arquivo,dS_data_arquivo,hS_hora_arquivo)

END
TableSort(TABLE_LISTA_ARQUIVOS,"-TABLE_lista_ar
De matos
May 29 2018
ARQUIVOS DIRETORIO
EDT_DIRETORIO = fSelectDir("", "")

s_arquivos_todos is string=fListFile(EDT_DIRETORIO+"\*.*")

s_arquivo_individual is string=""

FOR EACH STRING s_arquivo_individual OF s_arquivos_todos SEPARATED BY CR
gs_manifestacao="NAO"
EDT_xml_nome=s_arquivo_individual
EDT_xml=""
s_xml_documento is string=s_arquivo_individual
s_meu_xml is string=fLoadText(s_xml_documento)
IF s_meu_xml<>"" THEN
EDT_xml=s_meu_xml
_710_001_levar_notas_ind()
_801_Gravar_nota()
END
END
gb_importar_varios_xml=False
Info("Finalizado Importação ")

// BLOG COM EXEMPLO E VIDEO

https://www.youtube.com/watch?v=ccpqJG7a15I

http://windevdesenvolvimento.blogspot.com.br/2017/10/aula-1268-arquivos-022-ler-arquivos.html


De matos
Oct. 04 2017
Mostrar Arquivos de um Diretorio Ftp
PROCEDURE arquivo_mostra_local()
//leio o conteudo do diretorio e preencho tabela
TableDeleteAll(TABLE_local)
s_arquivo_individual is string=""
s_arquivo_todos is string=fListFile(ftp_conf.endereco_local+"*.*") // mostra arquivos diretorio
s_nome_arquivo is string=""
s_tamanho_arquivo is string=""
d_data_arquivo is Date=""
h_hora_arquivo is Time=""
_atributos_arquivo is string=""

FOR EACH STRING s_arquivo_individual OF s_arquivo_todos SEPARATED BY CR
s_nome_arquivo=fExtractPath(s_arquivo_individual,fFileName+fExtension)
s_tamanho_arquivo=fSize(ftp_conf.endereco_local+s_nome_arquivo)
d_data_arquivo=fDate(ftp_conf.endereco_local+s_nome_arquivo)
h_hora_arquivo=fTime(ftp_conf.endereco_local+s_nome_arquivo)
TableAddLine(TABLE_local,s_nome_arquivo,s_tamanho_arquivo,d_data_arquivo,h_hora_arquivo)
// outras informacoes uteis
_atributos_arquivo=fAttribut(ftp_conf.endereco_local+s_nome_arquivo) // atribuito arquivo
Info(fExtractPath(s_arquivo_individual,fDisque)) // drive
Info(fExtractPath(s_arquivo_individual,fExtension)) // extensao
Info(fExtractPath(s_arquivo_individual,fFichier)) // nome arquivo
Info(fExtractPath(s_arquivo_individual,fRépertoire)) // diretorio
Info(fExtractPath(s_arquivo_individual, fRépertoire)) // diretorio
END

//http://windevdesenvolvimento.blogspot.com.br/2016/01/windev21-curso-201-ftp-mostrar-arquivos.html
De matos AMARILDO
Feb. 09 2016
Exemplo de Mostrar Arquivos de Um Diretorio
//lista arquivos
TableDeleteAll(TABLE_lista_arquivos)
s_arquivos_todos is string=fListFile(SAI_DIRETORIO+"*.*")
s_arquivo_individual is string=""
FOR EACH STRING s_arquivo_individual OF s_arquivos_todos SEPARATED BY CR
s_nome_arquivo is string=fExtractPath(s_arquivo_individual,fFileName+fExtension)
s_tamanho_arquivo is string=fSize(SAI_DIRETORIO+s_nome_arquivo)
dS_data_arquivo is Date=fDate(SAI_DIRETORIO+s_nome_arquivo)
hS_hora_arquivo is Time=fTime(SAI_DIRETORIO+s_nome_arquivo)
TableAddLine(TABLE_lista_arquivos,s_nome_arquivo,s_tamanho_arquivo,dS_data_arquivo,hS_hora_arquivo)
END
TableSort(TABLE_lista_arquivos,"-TABLE_lista_arquivos.COL_Data","-TABLE_lista_arquivos.COL_Hora")
//pesquisa diretorio
sRépertoire_ is string
sRépertoire_ = fSelectDir("", "")
SAI_DIRETORIO=sRépertoire_
//Blog com video e Exemplo
http://windevdesenvolvimento.blogspot.com.br/2016/02/curso-windev-arquivos-001-listar.html
De matos AMARILDO
Feb. 09 2016
Mostrar os Arquivos de Um Diretorio
PROCEDURE arquivo_mostra_local()
//leio o conteudo do diretorio e preencho tabela
TableDeleteAll(TABLE_local)
s_arquivo_individual is string=""
s_arquivo_todos is string=fListFile(ftp_conf.endereco_local+"*.*") // mostra arquivos diretorio
s_nome_arquivo is string=""
s_tamanho_arquivo is string=""
d_data_arquivo is Date=""
h_hora_arquivo is Time=""
_atributos_arquivo is string=""

FOR EACH STRING s_arquivo_individual OF s_arquivo_todos SEPARATED BY CR
s_nome_arquivo=fExtractPath(s_arquivo_individual,fFileName+fExtension)
s_tamanho_arquivo=fSize(ftp_conf.endereco_local+s_nome_arquivo)
d_data_arquivo=fDate(ftp_conf.endereco_local+s_nome_arquivo)
h_hora_arquivo=fTime(ftp_conf.endereco_local+s_nome_arquivo)
TableAddLine(TABLE_local,s_nome_arquivo,s_tamanho_arquivo,d_data_arquivo,h_hora_arquivo)
// outras informacoes uteis
_atributos_arquivo=fAttribut(ftp_conf.endereco_local+s_nome_arquivo) // atribuito arquivo
Info(fExtractPath(s_arquivo_individual,fDisque)) // drive
Info(fExtractPath(s_arquivo_individual,fExtension)) // extensao
Info(fExtractPath(s_arquivo_individual,fFichier)) // nome arquivo
Info(fExtractPath(s_arquivo_individual,fRépertoire)) // diretorio
Info(fExtractPath(s_arquivo_individual, fRépertoire)) // diretorio
END

De matos AMARILDO
Jan. 02 2016