Files.SetAttr

Top  Previous  Next

 

Syntax

function Files.SetAttr(FileName: string; Attr: integer): integer

 

Alternative Names

ibec_SetFileAttr

 

Description

Sets the file attributes for the file identified by FileName. File attributes Attr can be one or a combination of the following:

 

__faReadOnly

Item is a read only file or folder and cannot be modified.

__faHidden

Item is a hidden file or folder and cannot be seen by default.

__faSysFile

Item is a system file or folder.

__faDirectory

The entry is a folder.

__faArchive

File is a Windows archived file.

__faNormal

A normal file.

__faTemporary

Item is a temporary file or folder.

__faSymLink

A symbolic link.

__faCompressed

Item is a compressed file or folder.

__faEncrypted

Item is an encrypted file or folder.

__faAnyFile

Any file type, used in Files.Find.

 

The routine returns zero if successful and an error code otherwise, you can use that error code with Shell.GetErrorMessage for an error description.

 

See also

Files.GetAttr

 

Example

execute udsblock 

as

begin

  /* get current file attributes */

  attrs = Files.GetAttr('c:\data\myfile.txt');

 

  /* include 'read only' flag for the file attributes by using a bitwise OR from the Math namespace */ 

  newattrs = Math.Or(attrs, __faReadOnly);

 

  /* modify file attributes */

  Files.SetAttr('c:\data\myfile.txt', newattrs);

end