Attributes Property

 

Description

 

Sets or returns the attributes of files. Read/write or read-only, depending on the attribute.

 

PowerBASIC Syntax

 

PROPERTY GET Attributes () AS LONG

PROPERTY SET Attributes(BYVAL nAttributes AS LONG)

 

Arguments

 

nAttributes

LONG. The new value for the attributes of the specified file.

 

Settings

 

The nAttributes argument can have any of the following values or any logical combination of the following values:

 

Constant

Value

Description

Normal

0

Normal file. No attributes are set.

ReadOnly

1

Read-only file. Attribute is read/write.

Hidden

2

Hidden file. Attribute is read/write.

System

4

System file. Attribute is read/write.

Volume

8

Disk drive volume label. Attribute is read-only.

Directory

16

Folder or directory. Attribute is read-only.

Archive

32

File has changed since last backup. Attribute is read/write.

Alias

1024

Link or shortcut. Attribute is read-only.

Compressed

2048

Compressed file. Attribute is read-only.

 

Example [PowerBASIC]

 

#INCLUDE "windows.inc"

#INCLUDE "scrrun.inc"

 

DIM fso AS IFileSystem

DIM pFile AS IFile

DIM nAttr AS LONG

DIM strAttr AS STRING

 

' Create an instance of the FileSystemObject

fso = NEWCOM "Scripting.FileSystemObject"

' Get a reference to the IFile interface

pFile = fso.GetFile(UCODE$("C:\MyFolder\MyFile.txt"))

' Get and display the attributes

nAttr = pFile.Attributes

IF nAttr = 0 THEN strAttr = "[Normal]"

IF (nAttr AND 1) = 1 THEN strAttr += "[ReadOnly]"

IF (nAttr AND 2) = 2 THEN strAttr += "[Hidden]"

IF (nAttr AND 4) = 4 THEN strAttr += "[System]"

IF (nAttr AND 8) = 8 THEN strAttr += "[Volume]"

IF (nAttr AND 16) = 16 THEN strAttr += "[Directory]"

IF (nAttr AND 32) = 32 THEN strAttr += "[Archive]"

IF (nAttr AND 1024) = 1024 THEN strAttr += "[Alias]"

IF (nAttr AND 2048) = 2048 THEN strAttr += "[Compressed]"

MSGBOX "File attributes: " & strAttr

 

Valid XHTML 1.0 Transitional