ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / External file functions
  • Overview
  • Operations on the content of external files
  • Example
  • Handling files
  • Example
  • Handling the disks and their directories
  • Managing the files and directories in Android
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
WINDEV, WINDEV Mobile and WEBDEV propose several functions allowing you to manage the external files from your WINDEV or WINDEV Mobile applications or from your WEBDEV sites.
An external file is a file with direct access, also called "text file". The external files can have any type (".TXT", ".INI", ...). The external files can contain:
  • readable characters (in character string format),
  • non-readable characters (in binary format).
Caution: Do not confuse external file and HFSQL file. The HFSQL files are data files and they must be handled by the HFSQL functions.
WINDEV, WINDEV Mobile and WEBDEV propose three groups of functions used to handle:
  • the content of your external files,
  • the files found on your disks (file copy for instance),
  • the directories of your disks (directory creation for instance).
Operations on the content of external files
WINDEV, WINDEV Mobile and WEBDEV allow you to:
  • create, open and close your external files.
  • manage the lock for your external files.
  • read the content of your external files: read a line or a block of bytes (characters).
  • write into your external files: write a line, a character string or a section of memory.
  • move in your external files.
WINDEVWEBDEV - Server codePHP

Example

Your program manages a ".INI" file whose size exceeds 64KB. This ".INI" file is too large to be handled by the INI functions. The functions for managing external files allow you to handle this file.
To retrieve the content of this file: read the content of the file and assign the information read into a section of memory.
To modify the content of this file: add various information into this file at a given position.
This file must be partially locked in order to be updated: lock this file. This file will only be accessible by the application that locks it.
Handling files
WINDEV, WINDEV Mobile and WEBDEV allow you to:
  • compress and encrypt the files.
  • find out the characteristics of a file.
  • find out and modify the name and path of the files.
  • compare the content of several files.
  • list the files found in a directory by running a procedure that performs a process on each file.

Example

Your program supports large files containing confidential information. Encrypt and compress these files before transferring them by network.
Perform a search on your files and run a specific procedure on the files found.
Handling the disks and their directories
WINDEV, WINDEV Mobile and WEBDEV allow you to:
  • get information about the accessible directories and disks.
  • handling directories.
Managing the files and directories in Android
Android The management of directories in Android presents the following specific features:
  • By default, the current directory of an application corresponds to the "files" subdirectory that is automatically created at the root of the application setup directory.
  • The relative paths handled by the application are relative to this directory.
  • The full path of current directory is returned by fCurrentDir. By default, you have the ability to read and write in this directory.
  • The current directory can be modified by fCurrentDir.
  • The runtime directory (returned by fExeDir) corresponds to the application installation directory. By default, the applications are always installed in the /data/data/<package name>.<application name> directory.
  • 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).
  • The "databases" directory is also automatically created at the root of application installation directory to store the SQLite databases handled by the application (unless a specific path was specified during the connection). The path of the "databases" directory is returned by fDataDir.
  • To have a storage location common to several applications, use the external memory (SDCard for example). The path of a directory for storing files in the external storage space is returned by SysDirExternalStorage.
  • When connecting a device to the PC using the "mass storage" or "disk drive" mode, the SD Card is automatically unmounted from the device and is no longer accessible from it. All running applications installed on the SD Card are killed. While the SD Card is unmounted, you will not be able to:
    • start the applications installed on the SD Card.
    • access the SDCard from the applications run on the phone.
For more details, see:
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.
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
The TableTo functions Unit examples (WINDEV): The TableTo functions
[ + ] Exporting table data with the WLanguage functions.
The following topics are presented in this example:
1/ interfacing with Word and Excel
2/ sending data to the clipboard
3/ generating a text file
This example explains how to export the content of a table to a Word document, an Excel workbook, the clipboard or a text file via the following WLanguage functions: TableToWord, TableToExcel, ToClipboard, TableToText.
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
WD File Synchronization Complete examples (WINDEV): WD File Synchronization
[ + ] This example is used to synchronize two file directories in WLanguage. After the synchronization, the destination directory and the source directory are identical. The comparison is based on the presence and on the date of the files. This can be very useful to manage the backups.
In this example, we will present the functions for handling the files on disk.

Summary of the example supplied with WINDEV:
Select a source directory containing the files to save and a destination directory where these files will be saved. Start the synchronization. The application will compare the content of the two directories. If the file is not found, if the source file is more recent, then the file will be updated in the backup directory.
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
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/22/2023

Send a report | Local help