相思资源网 Design By www.200059.com
<%
'创建多级目录,可以创建不存在的根目录
'参数:要创建的目录名称,可以是多级
'返回逻辑值,True成功,False失败
'创建目录的根目录从当前目录开始
'---------------------------------------------------
Function CreateMultiFolder(ByVal CFolder)
Dim objFSO, PhCreateFolder, CreateFolderArray, CreateFolder
Dim i, ii, CreateFolderSub, PhCreateFolderSub, BlInfo
BlInfo = False
CreateFolder = CFolder
On Error Resume Next
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If Err Then
Err.Clear()
Exit Function
End If
CreateFolder = Replace(CreateFolder, "", "/")
If Left(CreateFolder, 1) = "/" Then
CreateFolder = Right(CreateFolder, Len(CreateFolder) -1)
End If
If Right(CreateFolder, 1) = "/" Then
CreateFolder = Left(CreateFolder, Len(CreateFolder) -1)
End If
CreateFolderArray = Split(CreateFolder, "/")
For i = 0 To UBound(CreateFolderArray)
CreateFolderSub = ""
For ii = 0 To i
CreateFolderSub = CreateFolderSub & CreateFolderArray(ii) & "/"
Next
PhCreateFolderSub = Server.MapPath(CreateFolderSub)
If Not objFSO.FolderExists(PhCreateFolderSub) Then
objFSO.CreateFolder(PhCreateFolderSub)
End If
Next
If Err Then
Err.Clear()
Else
BlInfo = True
End If
CreateMultiFolder = BlInfo
End Function
%>
'使用方法:
<% Response.Write CreateMultiFolder("/upload/2006/11/11/") &"<br>" %>
'函数的返回值为True(成功)或False(失败,可能是主机不支持FSO功能)
'创建多级目录,可以创建不存在的根目录
'参数:要创建的目录名称,可以是多级
'返回逻辑值,True成功,False失败
'创建目录的根目录从当前目录开始
'---------------------------------------------------
Function CreateMultiFolder(ByVal CFolder)
Dim objFSO, PhCreateFolder, CreateFolderArray, CreateFolder
Dim i, ii, CreateFolderSub, PhCreateFolderSub, BlInfo
BlInfo = False
CreateFolder = CFolder
On Error Resume Next
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If Err Then
Err.Clear()
Exit Function
End If
CreateFolder = Replace(CreateFolder, "", "/")
If Left(CreateFolder, 1) = "/" Then
CreateFolder = Right(CreateFolder, Len(CreateFolder) -1)
End If
If Right(CreateFolder, 1) = "/" Then
CreateFolder = Left(CreateFolder, Len(CreateFolder) -1)
End If
CreateFolderArray = Split(CreateFolder, "/")
For i = 0 To UBound(CreateFolderArray)
CreateFolderSub = ""
For ii = 0 To i
CreateFolderSub = CreateFolderSub & CreateFolderArray(ii) & "/"
Next
PhCreateFolderSub = Server.MapPath(CreateFolderSub)
If Not objFSO.FolderExists(PhCreateFolderSub) Then
objFSO.CreateFolder(PhCreateFolderSub)
End If
Next
If Err Then
Err.Clear()
Else
BlInfo = True
End If
CreateMultiFolder = BlInfo
End Function
%>
'使用方法:
<% Response.Write CreateMultiFolder("/upload/2006/11/11/") &"<br>" %>
'函数的返回值为True(成功)或False(失败,可能是主机不支持FSO功能)
标签:
一个可以自动创建多级目录的函数
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无一个可以自动创建多级目录的函数的评论...