ASP Attributes 属性

定义和用法

Attributes 属性用于设置或返回指定文件或文件夹的属性。

语法:

  1. FileObject.Attributes[=newattributes]
  2. FolderObject.Attributes[=newattributes]
参数 描述
newattributes 可选的。规定文件或文件夹的属性值。 可采用下列值之一或者下列值的组合: - 0 = 普通文件。没有设置任何属性。 - 1 = 只读文件。可读写。 - 2 = 隐藏文件。可读写。 - 4 = 系统文件。可读写。 - 16 = 文件夹或目录。只读。 - 32 = 上次备份后已更改的文件。可读写。 - 1024 = 链接或快捷方式。只读。 - 2048 = 压缩文件。只读。

针对 File 对象的例子

  1. <%
  2. dim fs,f
  3. set fs=Server.CreateObject("Scripting.FileSystemObject")
  4. set f=fs.GetFile("c:\test.txt")
  5. Response.Write("The attributes of the file are: ")
  6. Response.Write(f.Attributes)
  7. set f=nothing
  8. set fs=nothing
  9. %>

输出:

  1. The attributes of the file are: 32

针对 Folder 对象的例子

  1. <%
  2. dim fs,fo
  3. set fs=Server.CreateObject("Scripting.FileSystemObject")
  4. set fo=fs.GetFolder("c:\test")
  5. Response.Write("The attributes of the folder are: ")
  6. Response.Write(fo.Attributes)
  7. set fo=nothing
  8. set fs=nothing
  9. %>

输出:

  1. The attributes of the folder are: 16