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 = "file name:" & F2.name & "<br>"
s = S & "file short path name:" & F2.shortpath & "<br>"
s = S & "File Physical Address:" & F2. Path & "<br>"
s = S & "file attributes:" & F2. Attributes & "<br>"
s = S & "File size:" & f2.size & "<br>"
s = S & "file type:" & F2.type & "<br>"
s = S & "File creation time:" & F2. DateCreated & "<br>"
s = S & recent access time: & F2. Datelastaccessed & "<br>"
s = S & "Last modified:" & 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.
ReadOnly 1 read-only files.
Hidden 2 hidden files.
System 4 systems files.
Directory folder or directory.
Archive 32
Alias 1024 A link or shortcut.
Compressed 2048 compressed files.
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:\" > see if there is </a>
Simple Cut-and-paste function is implemented.
Three, File.Copy
Also belong to FSO. An application after the getfile. Simply copy the file to a location.
3,copyfile.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. Copy "D:\"
%>
<a href= "D:\" > see if there is </a>
The cnbruce.txt files that are in the same directory as this ASP page still exist.
Four, file. Delete
Obviously, the file is deleted directly.
4,delfile.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 "D:\"
Set F3 = fso. GetFile ("D:\cnbruce.txt")
%>
<a href= "D:\" > View is not the file of </a>
Of course, the FSO has not finished, such as uploading files, ASP to HTML, etc. need to use the FSO. The more wonderful is still in the back.