The FSO encapsulation class can be used to operate files using the DOS command.

Source: Internet
Author: User
<%
'----------------------------------------------------------------------
'Keep this declaration information during forwarding. This declaration does not affect your speed!
* Dosasp class v1.01 ***************** *******************
'Author: 9th Five-Year Plan
'Site: http://dosasp.fanhei.net you can download the latest version from http://fanhei.net/dosasp/dosasp.rar'
'Email: zhaoyao83@hotmail.com
'Copyright: All Rights Reserved. The source code is public and can be used for all purposes free of charge. However, after modification, the modified file must be
'Send a copy to the author and retain the author's copyright information.
'*************************************** *******************************
'----------------------------------------------------------------------
'----------------------------------------------------------------------
Class dosasp

Public FSO
Private sub class_initialize
Set FSO = server. Createobject ("scripting. FileSystemObject ")
End sub

'-----------------------------
Public Function exists (PATH) 'to determine whether the file directory exists
Exists = FSO. fileexists (PATH)
If not (exists) then
Exists = FSO. folderexists (PATH)
End if
End Function
'------------------------------
Public Function del (fullpath) 'deletes an object
Del = false
If exists (fullpath) then
On Error resume next
FSO. deletefile (fullpath)
If err. Number = 0 then
Del = true
End if
End if
End Function
'------------------------------
Public Function copy (sourcefile, destinationfile) 'Copy an object
Dim myfile
If reportfilestatus (sourcefile) = 1 then
Set myfile = FSO. GetFile (sourcefile)
Myfile. Copy (destinationfile)
Copyafile = 1
Else
Copyafile =-1
End if
End Function
'------------------------------
Public function MD (fullpath) 'creates a directory
If exists (fullpath) then
MD = false
Else
FSO. createfolder (fullpath) 'You can use set to obtain the directory path.
MD = true
End if
End Function
'------------------------------------
Public Function RD (fullpath) 'deletes a directory
If not (exists (fullpath) then
RD = false
Else
FSO. deletefolder (fullpath)
RD = true
End if
End Function

'------------------------------------
Public Function CD (PATH) 'Switch directory
If exists (PATH) then
Set Cd = FSO. getfolder (PATH)
End if
End Function
'----------------------------------
Public Function Ren (myold, mynew) 'file directory rename
Ren = false
Dim File
If exists (myold) then
If instr (mynew, "\")> 0 then
Mynew = right (s, Len (S)-(Limit Rev (mynew, "\",-1, vbtextcompare )))
End if
On Error resume next
Set file = FSO. GetFile (myold)
File. Name = mynew
If err. Number = 0 then
Ren = true
End if
Err. Clear
End if
'''''''''''''''''''''''''''''''''''''''' ''''''''
If Ren = false then
If exists (myold) then
If instr (mynew, "\")> 0 then
Dir2 = right (s, Len (S)-(Limit Rev (mynew, "\",-1, vbtextcompare )))
End if
On Error resume next
Set mdir = Cd (myold)
Mdir. Name = mynew
If err. Number = 0 then
Ren = true
End if
End if
End if
End Function

'------------------------------------
Public Function Dir (PATH) 'column directory
Dim F, F1, FC, S, flag
If exists (PATH) then
Set F = Cd (PATH)
Set fc = f. subfolders
Flag = 0
For each F1 in FC
Flag = Flag + 1
If flag <> 1 then
S = S & "|"
End if
S = S & f1.name
Next
Flag = 0
Set fc = f. Files
For each F1 in FC
Flag = Flag + 1
If Len (S) = 0 then
If flag <> 1 then
S = S & "|"
End if
Else
S = S & "|"
End if
S = S & f1.name
Next
Dir = s
Else
Dir = false
End if
End Function

Public sub msgbox (mystr)
Response. Write "<script language = VBScript> msgbox ("""
Response. Write mystr
Response. Write "") </SCRIPT>"
End sub

Private sub class_terminate
If isobject (FSO) then
Set FSO = nothing
End if
End sub
End Class
%>
Ex:
Set dos = new dosasp
Dos. msgbox (DOS. exists (server. mappath ("A") 'determines whether directory A exists and a dialog box is displayed.
Set dos = nothing

Run as long as you have the FSO permission.

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.