ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / External file functions
  • Identifying the attributes of a directory
  • Modifying the attributes of a directory (syntax 2)
  • Handling errors
  • Operating mode in Windows Vista (and later)
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
Returns or modifies the attributes of a directory.
Example
Reports and Queries
// Retrieve the attributes of a directory
ResAttribute = fDirAttribute("C:\MyDirectories")
IF ResAttribute <> "ERR" THEN
...
END
Syntax

Retrieving the attributes of a directory Hide the details

<Result> = fDirAttribute(<Directory 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 attributes of the directory ("AH" for example).
    The following letters are used:
    • R: Read-only directory. The directory can be accessed in read-only.
    • H: Hidden directory. The name of the directory is grayed or not visible in the explorer.
    • S: System directory. The directory is a system directory of Windows.
    • A: "Archive" directory. This attribute indicates that the directory can be archived. Some programs use this attribute to find out which directories have been saved.
    • D: Directory or subdirectory. The directory is a directory or a subdirectory.
    • C: Compressed directory (on NTFS partitions). The directory was automatically compressed when it was copied onto an NTFS partition (Windows NT or 2000).
<Directory path>: Character string
Name and full (or relative) path of directory (up to 260 characters). A UNC path can be used. This directory name may (or may not) end with "\".
Windows This parameter can be in Ansi or Unicode format.
Reports and Queries

Modifying the attributes of a directory Hide the details

<Result> = fDirAttribute(<Directory path> , <Directory 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 directory ("AH" for example),
    The following letters are used:
    • R: Read-only directory. The directory can be accessed in read-only.
    • H: Hidden directory. The name of the directory is grayed or not visible in the explorer.
    • S: System directory. The directory is a system directory of Windows.
    • A: "Archive" directory. This attribute indicates that the directory can be archived. Some programs use this attribute to find out which directories have been saved.
    • D: Directory or subdirectory. The directory is a directory or a subdirectory.
    • C: Compressed directory (on NTFS partitions). The directory was automatically compressed when it was copied onto an NTFS partition (Windows NT or 2000).
<Directory path>: Character string
Name and full (or relative) path of directory (up to 260 characters). A UNC path can be used. This directory name may (or may not) end with "\".
Windows This parameter can be in Ansi or Unicode format.
<Directory attributes>: Character string
One or more letters corresponding to the new attributes of the specified directory ("AH" for example). The order of the letters has no importance. The following letters are used:
  • R: Read-only directory. The directory can be accessed in read-only.
  • H: Hidden directory. The name of the directory is grayed or not visible in the explorer.
  • S: System directory. The directory is a system directory of Windows.
  • A: "Archive" directory. This attribute indicates that the directory can be archived. Some programs use this attribute to find out which directories have been saved.
Remarks

Identifying the attributes of a directory

To find out the different attributes of a directory, check whether one of the letters identifying an attribute is found in <Result>. This search can be performed by Position for example.
Reports and QueriesStored procedures

Modifying the attributes of a directory (syntax 2)

Once modified, the attributes of the directory correspond to the attributes specified with fDirAttribute. For example, if <Directory attributes> is set to "AR", the specified directory will become a read-only archive directory.
Special cases:
  • Modifying 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 directory (on the NTFS partitions): The "Compressed directory" attribute (letter C) cannot be modified. Regardless of the modification performed, the compressed directory will keep the "Compressed directory" attribute (letter C).

Handling errors

fDirAttribute throws an error in the following cases:
  • the specified directory does not exist,
  • the name of the directory is invalid,
  • the directory is locked by another application (only when attributes are modified),
  • the letters specified in <Directory attributes> do not correspond to directory attributes.
Reports and Queries

Operating mode in Windows Vista (and later)

If this function does not operate 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: To handle and/or modify the files or directories without administrator privileges, you should:
  • 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: 08/23/2022

Send a report | Local help