File. asp

Source: Internet
Author: User

File. asp

<%
Option explicit
'----- FSO object -----
Dim FS, ts, path
Path = request. servervariables ("path_translated ")
Path = left (path, Len (PATH)-8)
Set FS = server. Createobject ("scripting. FileSystemObject ")
'Textstream = fileobject. createtextfile (filename, overwrite, Unicode (true) orasc (false ))
Set Ts = FS. createtextfile (Path & "test.txt", true, false)
'Textstream = fileobject. opentextfile (filename, iomode, create, Format)
'Iomode: 1-read-only, 2-writable, 8-append
'Format:-1-unicode, 0-ascii,-2-original format
Set Ts = FS. opentextfile (Path & "test.txt", 1, true, 0)
'Fileobject. copyfile source, destination, Overwrite
FS. copyfile Path & "test.txt", Path & "testcopy.txt", true
FS. copyfile Path & "test.txt", Path & "testcopy2.txt", true
'Fileobject. deletefile filename, flag (whether to delete read-only files)
FS. deletefile Path & "testcopy2.txt", true
'Fileobject. fileexists (filename)
Response. Write (FS. fileexists (Path & "test.txt "))
Response. Write (FS. getextensionname (Path & "test.txt "))
Response. Write (FS. GetFile (Path & "test.txt "))
Response. Write (FS. getfilename (Path & "test.txt "))
FS. movefile Path & "testcopy.txt", Path & "testcopy.txt"
'Fileobject. copyfolder source, destination, Overwrite
'Fileobject. movefolder source, destination
'Fileobject. createfolder (Foldername) if the directory already exists, an error occurs.
'Fileobject. deletefolder Foldername, flag (whether to delete read-only)
'Fileobject. folderexists (Foldername)
Response. Write (FS. getfolder (PATH ))
Response. Write (FS. getparentfoldername (PATH ))
'Windowsfolder: 0 systemfolder: 1 temporaryfolder: 2
Response. Write (FS. getspecialfolder (0 ))
Response. Write (FS. gettempname)
Response. Write (FS. getdrive ("C :"))
Response. Write (FS. getdrivename (PATH ))
Response. Write (FS. driveexists ("G :"))
Dim drive
For each drive in FS. Drives
Response. Write (FS. getdrivename (drive ))
Next
Response. Write ("the current directory of the E disk is" & FS. getabsolutepathname (PATH ))
Response. Write ("the upper level of the path is" & FS. getabsolutepathname (Path &".."))
Response. Write ("subdirectory in the path" & FS. getabsolutepathname (Path & "test "))
'Return the file name that does not contain the extension.
Response. Write (FS. getbasename (Path & "test.txt "))

'----- textstream object -----
set Ts = FS. opentextfile (Path & "test.txt", 2, true, 0)
TS. write "I am a good boy. "& vbcrlf &" how are you? "
set Ts = FS. opentextfile (Path & "test.txt", 1, true, 0)
do while not ts. atendofline
response. write (TS. read (1)
loop
do while not ts. atendofstream
response. write (TS. readline)
loop
response. write ("Now the file pointer is in the" & TS. column & "column")
response. write "Now the file pointer is in the" & TS. line & "line"
TS. close
set Ts = FS. opentextfile (Path & "test.txt", 1, true, 0)
response. write (TS. readall)
set Ts = FS. opentextfile (Path & "test.txt", 1, true, 0)
TS. skip (5)
response. write (TS. read (1)
TS. skipline
response. write (TS. read (1)
'ts. writeblanklines (number of blank lines)
%>

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.