ASP 属性属性
ASP Attributes 属性用于返回或设置指定文件或文件夹的属性。属性使用以下数值定义:
- 0:普通文件
- 1:只读文件
- 2:隐藏文件
- 4:系统文件
- 6:文件夹或目录
- 32:自上次备份以来文件已更改
- 1024:链接或快捷方式
- 2048:压缩文件
句法:
对于文件对象:
FileObject.Attributes[=newattributes]
对于文件夹对象:
FolderObject.Attributes[=newattributes]
参数:此属性有一个参数,如上所述,如下所述:
- newattributes:它指定必须为给定文件或文件夹设置的属性。它是一个可选属性。
下面的示例演示了ASP Attributes 属性。
示例 1:以下代码返回文件的属性。
ASP
<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
'Getting the file
set f=fs.GetFile("d:\GFG.txt")
Response.Write("The attributes of the file are: ")
'Getting the attributes of the file
Response.Write(f.Attributes)
set f=nothing
set fs=nothing
%>
ASP
<%
dim fs,folder
set fs=Server.CreateObject("Scripting.FileSystemObject")
'Getting the folder
set folder=fs.GetFolder("d:\geeks")
Response.Write("The attributes of the folder are: ")
'Getting the attributes of the folder
Response.Write(folder.Attributes)
set folder=nothing
set fs=nothing
%>
输出:
The attributes of the file are: 1024
示例 2:以下代码返回文件夹的属性。
ASP
<%
dim fs,folder
set fs=Server.CreateObject("Scripting.FileSystemObject")
'Getting the folder
set folder=fs.GetFolder("d:\geeks")
Response.Write("The attributes of the folder are: ")
'Getting the attributes of the folder
Response.Write(folder.Attributes)
set folder=nothing
set fs=nothing
%>
输出:
The attributes of the folder are: 18