System.SysUtils.FileGetAttr

From Appmethod Libraries
Jump to: navigation, search

Object Pascal

function FileGetAttr(const FileName: string; FollowLink: Boolean = True): Integer;

C++

extern DELPHI_PACKAGE int __fastcall FileGetAttr(const System::UnicodeString FileName, bool FollowLink = true);

Properties

Type Visibility Source Unit Parent
function public
System.SysUtils.pas
System.SysUtils.hpp
System.SysUtils System.SysUtils

Description

Returns the file attributes of FileName. FileGetAttr returns the attributes of the file as a string of bits. This value is the same as the Attr field of a TSearchRec type. Check for individual attributes with code such as the following:


Attrs := FileGetAttr('MyFile.sys');
if (Attrs or faHidden) <> 0 then
   FileSetAttr('MyFile.sys', Attrs and SysUtils.faHidden)
else
   FileSetAttr('MyFile.sys', Attrs and (not SysUtils.faHidden));


Note: A return value of faInvalid indicates that an error occurred.

Note: See TSearchRec for a description of the individual attribute constants.

Note: If the specified file parameter is a symbolic link and the FollowLink parameter is set to True, the method is performed on the target file. If the first condition is True and the FollowLink parameter is set to False, the method will be performed on the symbolic link.

See Also


Code Examples