国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

在ASP中自動創建多級文件夾的函數(使用FSO)

2019-11-18 19:22:38
字體:
來源:轉載
供稿:網友

    fso中有個方法是CreateFolder,但是這個方法只能在其上一級文件夾存在的情況下創建新的文件夾,所以我就寫了一個自動創建多級文件夾的函數,在生成靜態頁面等方面使用非常方便.

函數:
 
' --------------------------------
' 自動創建指定的多級文件夾
' strPath為絕對路徑
' 引用請保留版權
' by im286_Anjer
' 2005-4-3
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("Scr        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 objFSO.FolderExists(strTmpPath) Then
                        ' 創建
                        objFSO.CreateFolder(strTmpPath)
                End If
        Next
        Set objFSO = Nothing
        If Err = 0 Then
                AutoCreateFolder = True
        Else
                AutoCreateFolder = False
        End If
End Function
 


調用方法:

MyPath = "C:/a/b/c/"
If AutoCreateFolder(MyPath) Then
        Response.Write "創建文件夾成功"
Else
        Response.Write "創建文件夾失敗"
End If 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平阳县| 年辖:市辖区| 师宗县| 衡水市| 庆元县| 个旧市| 邢台市| 加查县| 连江县| 随州市| 伊吾县| 屯门区| 东宁县| 浦江县| 通河县| 长沙县| 肥西县| 江永县| 天台县| 江津市| 分宜县| 嵊泗县| 监利县| 孝义市| 谷城县| 罗平县| 白朗县| 金昌市| 家居| 松阳县| 卢湾区| 布尔津县| 武宁县| 侯马市| 呼伦贝尔市| 会理县| 临西县| 大埔区| 霍山县| 保康县| 天长市|