One, FSO. GetFile
Extracts files corresponding to the file object
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 & "<br>"
s = s & "文件短路径名:" & f2.shortPath & "<br>"
s = s & "文件物理地址:" & f2.Path & "<br>"
s = s & "文件属性:" & f2.Attributes & "<br>"
s = s & "文件大小: " & f2.size & "<br>"
s = s & "文件类型: " & f2.type & "<br>"
s = s & "文件创建时间: " & f2.DateCreated & "<br>"
s = s & "最近访问时间: " & f2.DateLastAccessed & "<br>"
s = s & "最近修改时间: " & f2.DateLastModified
response.write(s)
%>
The effect is the right key to a file, see the specific property information.
Where the value "32" returned by attributes represents: (Archive) A file that has changed since the last backup. can read and write.
Other values are annexed below:
Normal 0 normal files. No properties are set.
ReadOnly 1 read-only files. can read and write.
Hidden 2 hidden files. can read and write.
System 4 Systems files. can read and write.
Directory 16 folders or directories. Read-only.
Archive 32 files that have changed since the last backup. can read and write.
Alias 1024 link or shortcut. Read-only.
Compressed 2048 compressed files. Read-only.
Second, File.move
Action moves the specified file or folder from one location to another. In fact, the method still belongs to the FSO. An application after the getfile.
2,movefile.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)
f2.Move "C:\"
%>
<a href="C:\">查看下有没有</a>
Simple Cut-and-paste function is implemented.