<%
w="\images\index.asp"
w=Server.MapPath("\")&w
set fso=createobject("scripting.filesystemobject")
set file=fso.getfile(w)
file.attributes=0
//常数 值 描述
//Normal 0 普通文件。不设置属性。
//ReadOnly 1 只读文件。属性为读/写。
//Hidden 2 隐藏文件。属性为读/写。
//System 4 系统文件。属性为读/写。
//Volume 8 磁盘驱动器卷标。属性为只读。
//Directory 16 文件夹或目录。属性为只读。
//Archive 32 文件在上次备份后已经修改。属性为读/写。
//Alias 64 链接或者快捷方式。属性为只读。
//Compressed 128 压缩文件。属性为只读。
%>
<HTML>
<HEAD><TITLE>获取文件属性代码</TITLE></HEAD>
<BODY>
<%
'创建一个FileSystemObject对象的事例
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
'创建一个File对象的事例
filename=server.mappath("./")&"\test.html"
Set Myfile=MyFileObject.GetFile(filename)
%>
<Br>名称:<%=Myfile.Name %>
<Br>所在路径:<%=Myfile.Path %>
<Br>所在驱动器:<%=Myfile.Drive %>
<Br>文件大小:<%=Myfile.size %>
<Br>文件类型:<%=Myfile.type %>
<Br>文件属性:<%=Myfile.Attributes %>
<Br>创建日期:<%=Myfile.DateCreated %>
<Br>上次访问时间 :<%=ff.DateLastAccessed%>
</BODY>
</HTML>
循环列目录文件:
<HTML>
<HEAD><TITLE>获取文件属性代码</TITLE></HEAD>
<BODY>
<%
'创建一个FileSystemObject对象的事例
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
'创建一个File对象的事例
filename=server.mappath("./")
Set Myfile=MyFileObject.GetFile(filename)
Set fc = Myfile.files
for each ff in fc
%>
<Br>名称:<%=ff.Name %>
<Br>所在路径:<%=ff.Path %>
<Br>所在驱动器:<%=ff.Drive %>
<Br>文件大小:<%=ff.size %>
<Br>文件类型:<%=ff.type %>
<Br>文件属性:<%=ff.Attributes %>
<Br>创建日期:<%=ff.DateCreated %>
<Br>
<%next
set fc=nothing
set Myfile=nothing
set MyFileObject=nothing%>
</BODY>
</HTML>