ASP Attributes Property

Definition and Usage

The Attributes property is used to set or return the attributes of a specified file or folder.

Syntax:

FileObject.Attributes[=newattributes]
FolderObject.Attributes[=newattributes]
Parameter Description
newattributes

Optional. Specifies the attribute value of the file or folder.

One of the following values can be used, or a combination of the following values:

  • 0 = Normal file. No attributes set.
  • 1 = Read-only file. Read and write.
  • 2 = Hidden file. Read and write.
  • 4 = System file. Read and write.
  • 16 = Folder or directory. Read-only.
  • 32 = File has been changed since last backup. Read and write.
  • 1024 = Link or shortcut. Read-only.
  • 2048 = Compressed file. Read-only.

Example for File object

<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.GetFile("c:\test.txt")
Response.Write("The attributes of the file are: ")
Response.Write(f.Attributes)
set f=nothing
set fs=nothing
%>

Output:

The attributes of the file are: 32

Example for Folder object

<%
dim fs,fo
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fo=fs.GetFolder("c:\test")
Response.Write("The attributes of the folder are: ")
Response.Write(fo.Attributes)
set fo=nothing
set fs=nothing
%>

Output:

The attributes of the folder are: 16