Attributes Property |
Description
Sets or returns the attributes of folders. Read/write or read-only, depending on the attribute.
PowerBASIC Syntax
Arguments
Example [PowerBASIC]
#INCLUDE "windows.inc" #INCLUDE "scrrun.inc"
DIM fso AS IFileSystem DIM pFolder AS IFolder DIM nAttr AS LONG DIM strAttr AS STRING
' Create an instance of the FileSystemObject fso = NEWCOM "Scripting.FileSystemObject" ' Get a reference to the IFolder interface pFolder = fso.GetFolder(UCODE$("C:\MyFolder\")) ' Get and display the attributes nAttr = pFolder.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 "Folder attributes: " & strAttr
Example [PowerBASIC]
DIM fso AS IFileSystem DIM pFolder AS IFolder DIM nAttr AS LONG DIM strAttr AS STRING
' Create an instance of the FileSystemObject fso = NEWCOM "Scripting.FileSystemObject" ' Get a reference to the IFolder interface pFolder = fso.GetFolder(UCODE$("C:\MyFolder\")) ' Get and display the attributes nAttr = pFolder.Attributes ' Set the attribute pFolder.Attributes = %FileAttribute_ReadOnly IF OBJRESULT = %S_OK THEN PRINT "Attributes set" ELSE PRINT "Error &H" & HEX$(OBJRESULT) & " setting the attribute" END IF
|