Below is a collection of common ASP tutorials in the development of the file and folder operation functions, there are file creation, deletion and folder deletion, create and other functions.
<%
' File action function: Write file
Private Sub WriteFile (Filename,text)
Dim fso,file
Set fso = CreateObject ("Scripting.FileSystemObject")
Set file = Fso.createtextfile (filename, true)
File.write (text)
File.close
Set file = Nothing
Set fso = Nothing
End Sub
' File action function: Read file
function ReadFile (filename)
Dim fso,file
Set fso = CreateObject ("Scripting.FileSystemObject")
Set file = Fso.opentextfile (filename, 1)
ReadFile = File.readall ()
File.close
Set file = Nothing
Set fso = Nothing
End Function
' Test whether the folder exists
function Checkfolder (folder)
Dim fso,exists
Set fso = CreateObject ("Scripting.FileSystemObject")
Checkfolder = fso.folderexists (folder)
Set fso = Nothing
End Function
' Create a folder
Private Sub CreateFolder (folder)
Dim fso
Set fso = CreateObject ("Scripting.FileSystemObject")
Fso.createfolder (folder)
Set fso = Nothing
End Sub
' Delete folder
Private Sub DeleteFolder (folder)
Dim fso
Set fso = CreateObject ("Scripting.FileSystemObject")
Fso.deletefolder (Server.MapPath (folder))
Set fso = Nothing
End Sub
' Delete file
Private Sub DeleteFile (fname)
Set fso = CreateObject ("Scripting.FileSystemObject")
If Fso.fileexists (Server.MapPath (fname)) Then
Set F = Fso.getfile (Server.MapPath (fname))
F.delete ()
Set F = Nothing
End If
Set fso = Nothing
End Sub
' Test whether the folder exists, does not exist is established
Private Sub Checksavepath (Filesavepath)
P_tmp = Split (Filesavepath, "/")
Path = ""
For i = 0 To UBound (p_tmp)
If p_tmp (i) = "" Then
Path = path & "/"
Else
Path = path & P_tmp (i) & "/"
If not Checkfolder (Server.MapPath (path)) then call CreateFolder (Server.MapPath (path))
End If
Next
End Sub
%>