ASP learning the FSO component Operation example Skill (9)

Source: Internet
Author: User
Tags copy file size backup
fso| Skills

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. CloseSet 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 properties:" & F2. Attributes & "<br>"
  s = S & File Size: "& f2.size &" <br> "s = S &" file type: "&A mp 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. 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.

Two, 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. CloseSet 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. CloseSet 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.







Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.