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
  • Identifying the files attributes
  • Modifying the attributes of a file (syntax 2)
  • Handling errors
  • Operating mode in Windows Vista (and later)
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Returns or modifies the attributes of a file.
AndroidAndroid Widget JavaPHP In this version, you can only find out the file attributes.
// Récupération des attributs d'un fichier
ResAttribut = fAttribute(CheminFichier + "\Fichier.txt")
IF ResAttribut <> "ERR" THEN
	...
END
Syntax

Retrieving the attributes of a file or directory Hide the details

<Result> = fAttribute(<File path>)
<Result>: Character string
  • "ERR" if an error occurred. To get more details on the error, use ErrorInfo with the errMessage constant.
  • One or more letters corresponding to the file attributes ("AH" for example).
    The following letters are used:
    • R: Read-only file. The file can be accessed in read-only.
    • H: Hidden file. The file name is grayed or invisible in the explorer.
      PHP This value is not available.
    • S System file. The file is a Windows system file.
      AndroidAndroid Widget JavaPHP This value is not available.
    • A: "Archive" file. This attribute indicates that the file can be archived. Some programs use this attribute to determine which files have been saved.
      LinuxAndroidAndroid Widget iPhone/iPadIOS WidgetMac CatalystJavaPHP This value is not supported.
    • D: Directory or sub-directory. The file is a directory or a subdirectory.
    • C Compressed file (on NTFS partitions). This file was automatically compressed during its copy on an NTFS partition (Windows NT or 2000).
      AndroidAndroid Widget JavaPHP This value is not available.
    • L: Reader. This name corresponds to the volume name of one of the disks accessible from the computer.
      PHP This value is not available.
<File path>: Character string
Name and full or relative path of the file (up to 260 characters). A UNC path can be used.
WindowsLinux This parameter can be in Ansi or Unicode format.
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.
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPadIOS WidgetMac CatalystUser code (UMC)Ajax

Modifying the attributes of a file or directory Hide the details

<Result> = fAttribute(<File path> , <File attributes>)
<Result>: Character string
  • "ERR" if an error occurred. To get more details on the error, use ErrorInfo with the errMessage constant.
  • One or more letters corresponding to the new attributes of the file ("AH" for example):. The following letters are used:
    • R: Read-only file. The file can be accessed in read-only.
    • H: Hidden file. The file name is grayed or invisible in the explorer.
    • S System file. The file is a Windows system file.
    • A: "Archive" file. This attribute indicates that the file can be archived. Some programs use this attribute to determine which files have been saved.
    • D: Directory or sub-directory. The file is a directory or a subdirectory.
    • C Compressed file (on NTFS partitions). This file was automatically compressed during its copy on an NTFS partition (Windows NT or 2000).
<File path>: Character string
Name and full or relative path of the file (up to 260 characters). A UNC path can be used.
WindowsLinux This parameter can be in Ansi or Unicode format.
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.
<File attributes>: Character string
One or more letters corresponding to the new attributes of the specified file ("AH" for example). The order of the letters has no importance. The following letters are used:
  • R: Read-only file. The file can be accessed in read-only.
  • H: Hidden file. The file name is grayed or invisible in the explorer.
  • S System file. The file is a Windows system file.
  • A: "Archive" file. This attribute indicates that the file can be archived. Some programs use this attribute to determine which files have been saved.
  • "" (empty string). All the attributes are disabled.
Remarks

Identifying the files attributes

To retrieve the different attributes of a file, check whether one of the letters identifying an attribute is found in <Result>. This search can be performed by Position for example.
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPadIOS WidgetMac CatalystUser code (UMC)Ajax

Modifying the attributes of a file (syntax 2)

Once modified, the attributes of the file correspond to the attributes specified with fAttribute. For example, if <File attributes> corresponds to "AR", the specified file will become a read-only archive file.
Special cases:
  • Modifying a directory or a subdirectory: the "Directory or subdirectory" attribute (letter D) cannot be modified. Regardless of the modification performed, the directory (or the subdirectory) will keep the "Directory and subdirectory" attribute (letter D).
  • Modifying a compressed file (on NTFS partitions): the "Compressed file" attribute (letter C) cannot be modified. Regardless of the modification performed, the compressed file will keep the "Compressed file" attribute (letter C).

Handling errors

fAttribute throws an error in the following cases:
  • the specified file does not exist,
  • the name of the specified file is invalid,
  • the specified file is opened or locked by another application (when modifying the attributes only),
  • the letters specified in <File attributes> do not correspond to file attributes.
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)

Operating mode in Windows Vista (and later)

If this function does not work properly in Windows Vista (and later), check whether the file or directory used is not in one of the system directories (Windows directory or "Program Files" directory).
In Windows Vista (and later), with the UAC mechanism (User Account Control) enabled, you must have administrator privileges to handle and/or modify the files or directories in system directories (Windows directory or "Program Files" directory).
Programming tip: If you need to manipulate / modify files or directories, without needing administrator privileges, it is advisable:
  • avoid writing to the Windows directory or to the "Program Files" directory,
  • use the system directory of the application (returned by SysDir with the srAppDataCommun constant, for example).
Component: wd300std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help