ASP programming introduction (18): FSO components File operation (below)

xiaoxiao2021-03-06  38

First, fso.getfile extraction file corresponding 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.closset F2 = fso.getfile (Whichfile) S = "file name:" & f2.name & "
" S = S & "file short path name:" & f2.shortpath & "
"S = S &" file physical address: "& f2.path &"
"S = S &" file properties: "& f2.attributes &"
"S = S &" file size: " & F2.size & "
" S = S & "file type:" & f2.type & "
" S = S & "file creation time:" & f2.datecreated & "
" S = S & "Recent Access Time:" & f2.dateLastAccessed & "
" S = S & "Recent modified time:" & f2.dateLastModifiedResponse.write (s)%>

Its effect is just a file, and the specific attribute information is seen. Where the value "32" returned by Attribute is "32" indicates that the file has been changed after the last backup. Ready to be read. The appendix of other values ​​is as follows:

Normal 0 normal file. No properties are set. Readonly 1 reads file. Ready to be read. Hidden 2 hides files. Ready to be read. System 4 system file. Ready to be read. Directory 16 folder or directory. Read only. Archive 32 The file has been changed after the last backup. Ready to be read. Alias ​​1024 links or shortcuts. Read only. Compressed 2048 Compressed file. Read only.

Second, File.move action moves the specified file or folder from a location to another. In fact, this method is still an application after fso.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.closset F2 = fso.getfile (Whichfile) F2.move "C: /"%> Viewing the functional implementation of the "simple shear paste" . Third, file.copy also belongs to an application after fso.getfile. Just simply copy files 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.closset F2 = fso.getfile (Whichfile) F2.copy "D: /"%> View Under Is there

The CNBRUCE.TXT file with this ASP page is still present. Fourth, file.delete is obvious, it is directly deleted files. 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.closset F2 = fso.getfile (Whichfile) f2.move "d: /" set f3 = fso.getfile ("d: /cnbruce.txt") f3.delete%> View below is the

转载请注明原文地址:https://www.9cbs.com/read-70345.html

New Post(0)