<%
'Create multi-level directory, you can create root directory that does not exist
'Parameter: The directory name to be created, can be multi-level
'Return logical value, True succeeds, False fails
'Create the root directory of the directory starts from the current directory
'---------------------------------------------------
FunctionCreateMultiFolder(ByValCFolder)
DimobjFSO, PhCreateFolder, CreateFolderArray, CreateFolder
Dimi, ii, CreateFolderSub, PhCreateFolderSub, BlInfo
BlInfo=False
CreateFolder=CFolder
OnErrorResumeNext
SetobjFSO=Server.CreateObject("Scripting.FileSystemObject")
IfErrThen
Err.Clear()
ExitFunction
EndIf
CreateFolder=Replace(CreateFolder,"","/")
IfLeft(CreateFolder,1)="/"Then
CreateFolder=Right(CreateFolder,Len(CreateFolder)-1)
EndIf
IfRight(CreateFolder,1)="/"Then
CreateFolder=Left(CreateFolder,Len(CreateFolder)-1)
EndIf
CreateFolderArray=Split(CreateFolder,"/")
Fori=0ToUBound(CreateFolderArray)
CreateFolderSub=""
Forii=0Toi
CreateFolderSub=CreateFolderSub&CreateFolderArray(ii)&"/"
Next
PhCreateFolderSub=Server.MapPath(CreateFolderSub)
IfNotobjFSO.FolderExists(PhCreateFolderSub)Then
objFSO.CreateFolder(PhCreateFolderSub)
EndIf
Next
IfErrThen
Err.Clear()
Else
BlInfo=True
EndIf
CreateMultiFolder=BlInfo
EndFunction
%>
'How to use: