最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ASP编程入门进阶(十八):FSO组件之文件操作(下)
时间:2008-01-18 编辑:简简单单 来源:一聚教程网
一,fso.GetFile
提取文件相应的 File 对象
1,getfile.asp
<%
whichfile=Server.MapPath("cnbruce.txt")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile(whichfile,true)
f1.Write ("This is a test.My Name is cnbruce.")
f1.Close
Set f2 = fso.GetFile(whichfile)
s = "文件名称:" & f2.name & "
"
s = s & "文件短路径名:" & f2.shortPath & "
"
s = s & "文件物理地址:" & f2.Path & "
"
s = s & "文件属性:" & f2.Attributes & "
"
s = s & "文件大小: " & f2.size & "
"
s = s & "文件类型: " & f2.type & "
"
s = s & "文件创建时间: " & f2.DateCreated & "
"
s = s & "最近访问时间: " & f2.DateLastAccessed & "
"
s = s & "最近修改时间: " & f2.DateLastModified
response.write(s)
%>
其效果正如右键某文件,看到的具体属性信息。
其中Attributes返回的数值“32”表示:(Archive)上次备份后已更改的文件。可读写。
其它值附录如下:
Normal 0 普通文件。
没有设置任何属性。
ReadOnly 1 只读文件。
可读写。
Hidden 2 隐藏文件。
可读写。
System 4 系统文件。
可读写。
Directory 16 文件夹或目录。
只读。
Archive 32 上次备份后已更改的文件。
可读写。
Alias 1024 链接或快捷方式。
只读。
Compressed 2048 压缩文件。
只读。
二,file.move
作用将指定的文件或文件夹从某位置移动到另一位置。其实该方法仍然属于fso.GetFile后的一个应用。
提取文件相应的 File 对象
1,getfile.asp
<%
whichfile=Server.MapPath("cnbruce.txt")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile(whichfile,true)
f1.Write ("This is a test.My Name is cnbruce.")
f1.Close
Set f2 = fso.GetFile(whichfile)
s = "文件名称:" & f2.name & "
"
s = s & "文件短路径名:" & f2.shortPath & "
"
s = s & "文件物理地址:" & f2.Path & "
"
s = s & "文件属性:" & f2.Attributes & "
"
s = s & "文件大小: " & f2.size & "
"
s = s & "文件类型: " & f2.type & "
"
s = s & "文件创建时间: " & f2.DateCreated & "
"
s = s & "最近访问时间: " & f2.DateLastAccessed & "
"
s = s & "最近修改时间: " & f2.DateLastModified
response.write(s)
%>
其效果正如右键某文件,看到的具体属性信息。
其中Attributes返回的数值“32”表示:(Archive)上次备份后已更改的文件。可读写。
其它值附录如下:
Normal 0 普通文件。
没有设置任何属性。
ReadOnly 1 只读文件。
可读写。
Hidden 2 隐藏文件。
可读写。
System 4 系统文件。
可读写。
Directory 16 文件夹或目录。
只读。
Archive 32 上次备份后已更改的文件。
可读写。
Alias 1024 链接或快捷方式。
只读。
Compressed 2048 压缩文件。
只读。
二,file.move
作用将指定的文件或文件夹从某位置移动到另一位置。其实该方法仍然属于fso.GetFile后的一个应用。
相关文章
- asp fso文件操作介绍 05-19
- asp 建立文件夹(递归) 10-08
- asp filesystemobject 文件系统例子 09-05
- 如何使用ASP文件对象 03-04
- asp 文件采集代码 12-04
- asp 创建文件与文件夹 07-11