<%
'功能:删除一个目录。除目录本身外,还将删除指定目录下的所有子目录和文件。用于删除目录树。
'RD [Drive:]Path
'支持删除多级目录,支持相对路径和绝对路径。
'支持用“...”指定父目录的父目录。
''需要PATH函数在下面
Function RD(ByVal sPath)
On Error Resume Next
Dim oFSO
sPath = Path(sPath) '//此处需要PATH函数
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
If oFSO.FolderExists(sPath) Then
oFSO.DeleteFolder sPath, True
RD = True
End If
Set oFSO = Nothing
If Err.Number > 0 Then
Err.Clear()
RD = False
Else
RD = True
End If
End Function
%>
<%
'功能:创建目录。
'MD [Drive:]Path
'支持创建多级目录,支持相对路径和绝对路径。
'支持用“...”指定父目录的父目录。
'需要PATH函数在下面
Function MD(sPath)
On Error Resume Next
Dim aPath, iPath, i, sTmpPath
Dim oFSO
sPath = Path(sPath) '//此处需要PATH函数
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
If oFSO.FolderExists(sPath) Then MD = True : Exit Function
aPath = Split(sPath, "\")
iPath = UBound(aPath)
sTmpPath = ""
For i = 0 To iPath
sTmpPath = sTmpPath & aPath(i) & "\"
If Not oFSO.FolderExists(sTmpPath) Then
oFSO.CreateFolder(sTmpPath)
End If
Next
Set oFSO = Nothing
If Err.Number > 0 Then
Err.Clear()
MD = False
Else
MD = True
End If
End Function
%>
<%
'功能:计算目录绝对路径。
'PATH [Drive:]Path
'支持多级目录,支持相对路径和绝对路径。
'支持用“...”指定父目录的父目录。
Function Path(ByVal sPath)
On Error Resume Next
If Len(sPath&"") = 0 Then sPath = "./"
If Right(sPath, 1) = ":" Then sPath = sPath & "\"
sPath = Replace(sPath, "/", "\")
sPath = ReplaceAll(sPath, "\\", "\", False)
sPath = ReplaceAll(sPath, "...", "..\..", False)
If (InStr(sPath, ":") > 0) Then
sPath = sPath
Else
sPath = Server.Mappath(sPath)
End If
Path = sPath
End Function
%>
联系客服