<%
'功能:刪除一個(gè)目錄。除目錄本身外,還將刪除指定目錄下的所有子目錄和文件。用于刪除目錄樹。
'RD [Drive:]Path
'支持刪除多級(jí)目錄,支持相對(duì)路徑和絕對(duì)路徑。
'支持用“...”指定父目錄的父目錄。
''需要PATH函數(shù)在下面
Function RD(ByVal sPath)
On Error Resume Next
Dim oFSO
sPath = Path(sPath) '//此處需要PATH函數(shù)
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
%>
<%
'功能:創(chuàng)建目錄。
'MD [Drive:]Path
'支持創(chuàng)建多級(jí)目錄,支持相對(duì)路徑和絕對(duì)路徑。
'支持用“...”指定父目錄的父目錄。
'需要PATH函數(shù)在下面
Function MD(sPath)
On Error Resume Next
Dim aPath, iPath, i, sTmpPath
Dim oFSO
sPath = Path(sPath) '//此處需要PATH函數(shù)
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
%>
<%
'功能:計(jì)算目錄絕對(duì)路徑。
'PATH [Drive:]Path
'支持多級(jí)目錄,支持相對(duì)路徑和絕對(duì)路徑。
'支持用“...”指定父目錄的父目錄。
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
%>
聯(lián)系客服