FSO中有個方法是CreateFolder,但是這個方法只能在其上一級文件夾存在的情況下創(chuàng)建新的文件夾,所以我就寫了一個自動創(chuàng)建多級文件夾的函數(shù),在生成靜態(tài)頁面等方面使用非常方便.
創(chuàng)新互聯(lián)建站是一家朝氣蓬勃的網(wǎng)站建設(shè)公司。公司專注于為企業(yè)提供信息化建設(shè)解決方案。從事網(wǎng)站開發(fā),網(wǎng)站制作,網(wǎng)站設(shè)計,網(wǎng)站模板,微信公眾號開發(fā),軟件開發(fā),小程序開發(fā),十余年建站對成都玻璃隔斷等多個行業(yè),擁有豐富的網(wǎng)站維護(hù)經(jīng)驗。
函數(shù):
' --------------------------------
' 自動創(chuàng)建指定的多級文件夾
' strPath為絕對路徑
' 引用請保留版權(quán)
' 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("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 objFSO.FolderExists(strTmpPath) Then
' 創(chuàng)建
objFSO.CreateFolder(strTmpPath)
End If
Next
Set objFSO = Nothing
If Err = 0 Then
AutoCreateFolder = True
Else
AutoCreateFolder = False
End If
End Function
調(diào)用方法:
MyPath = "C:abc"
If AutoCreateFolder(MyPath) Then
Response.Write "創(chuàng)建文件夾成功"
Else
Response.Write "創(chuàng)建文件夾失敗"
End If
網(wǎng)頁題目:FSO創(chuàng)建多級文件夾
本文網(wǎng)址:http://jinyejixie.com/article8/echeop.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁設(shè)計公司、微信公眾號、靜態(tài)網(wǎng)站、用戶體驗、網(wǎng)站改版、網(wǎng)站設(shè)計
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容