Asp学习站欢迎你!

关于创建多级文件夹的ASP函数实例

来源:ASP学习网 作者:Admin 时间:08-04-16 点击:

FileSystemObject中有个方法创建文件夹的方法CreateFolder,但是这个方法只能在其上一级文件夹存在的情况下创建新的文件夹,所以我就写了一个自动创建多级文件夹的函数,在生成静态页面等方面使用非常方便。函数如下:
以下为引用的内容:
'--------------------------------
'自动创建指定的多级文件夹
'strPath为绝对路径
Function AutoCreateFolder(strPath) 'As Boolean
        On Error Resume Next
        Dim astrPath, ulngPath, i, strTmpPath
        Dim objFSO
        If InStr(strPath, "\") <=0 or InStr(strPath, ":") <= 0 Then
                AutoCreateFolder = False
                Exit Function
        End If
        Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
        If objFSO.FolderExists(strPath) Then
                AutoCreateFolder = True
                Exit Function
        End If
        astrPath = Split(strPath, "\")
        ulngPath = UBound(astrPath)
        strTmpPath = ""
        For i = 0 To ulngPath
                strTmpPath = strTmpPath & astrPath(i) & "\"
                If Not ob

标签: 实例, 创建】 【打印】 【关闭
最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 验证码: 验证码 查看所有评论