%
'***********************************************************************************************************
'作 者: 趙敏 flash90@sohu.com
'頁面名稱: CreateFolder.asp
'頁面功能: 生成n層目錄的文件夾
'使用方法: 調用CheckFolder()函數(shù),例如: CheckFolder(path)
'傳入?yún)?shù): 即將上傳的文件的相對路徑,例如: path = "./upload/bbb/ccc/ddd"
'缺 點: 必須在參數(shù)path里面帶上upload文件夾
'***********************************************************************************************************
Sub CheckFolder(path)
SplitPath(path)
End Sub
Sub SplitPath(path)
dim Road '物理路徑
Road = Server.Mappath("./upload")
dim CurRoad '當前路徑
Road = Split(Road,"\&;,-1,1)
CurRoad = Road(UBound(Road))
dim folder,FSO
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
folder = Split(path,"\&;,-1,1)
for i = 0 to UBound(folder) step 1
if folder(i) = CurRoad then
j = i
exit for
end if
Next
i = j + 1
if i = UBound(folder) then
dim myroad
myroad = Server.MapPath(".\upload")
for i = j + 1 to UBound(folder) step 1
CreateFolder myroad,folder(i)
myroad = myroad "/" folder(i)
Next
end if
End Sub
Sub CreateFolder(mypath,folderName)
Dim fso,f
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if Not(fso.FolderExists(mypath+"/"+folderName)) then
set f = fso.CreateFolder(mypath+"/"+folderName)
end if
End Sub
Set fso = nothing
%>