ASP Attributes 属性

定义和用法

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

语法:

FileObject.Attributes[=newattributes]
FolderObject.Attributes[=newattributes]
参数 描述
newattributes

可选的。规定文件或文件夹的属性值。

可采用下列值之一或者下列值的组合:

  • 0 = ไฟล์ทั่วไป ไม่มีการตั้งค่าคุณสมบัติใดๆ
  • 1 = ไฟล์ที่เปิดใช้งานแบบแค่อ่าน และสามารถเข้าถึงได้ทั้งการเข้าอ่านและการเขียน
  • 2 = ไฟล์ที่ซ่อน และสามารถเข้าถึงได้ทั้งการเข้าอ่านและการเขียน
  • 4 = ไฟล์ระบบ และสามารถเข้าถึงได้ทั้งการเข้าอ่านและการเขียน
  • 16 = โฟลเดอร์หรือไดเรกทอรี และไม่สามารถเข้าถึงได้
  • 32 = ไฟล์ที่ถูกเปลี่ยนแปลงหลังจากการสำรองข้อมูล และสามารถเข้าถึงได้ทั้งการเข้าอ่านและการเขียน
  • 1024 = ลิงก์หรือทางเข้ารวม และไม่สามารถเข้าถึงได้
  • 2048 = ไฟล์ที่ถูกบีบอกด้วยโปรแกรมคอมเพรสชัน และไม่สามารถเข้าถึงได้

针对 File 对象的例子

<%
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
%>

การออกแบบ:

The attributes of the file are: 32

针对 Folder 对象的例子

<%
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
%>

การออกแบบ:

คุณสมบัติของโฟลเดอร์คือ: 16