asp中創(chuàng)建多級目錄的兩段代碼
實(shí)現(xiàn)代碼一、比較專業(yè)看起來
'============================== '創(chuàng)建多級目錄,可以創(chuàng)建不存在的根目錄 '參數(shù):要創(chuàng)建的目錄名稱,可以是多級 '創(chuàng)建目錄的根目錄從當(dāng)前目錄開始 '''調(diào)用舉例 ''Call CreateMultiFolder("/upload/jumbot/myphoto/") '============================== 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 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
上面的是循環(huán)
實(shí)現(xiàn)方法二、
'自動創(chuàng)建多極目錄 'code by jb51 reterry function createit(path) dim fsofo,cinfo,thepath,thepatharray dim i,ii,binfo binfo=false thepath=path set fsofo=createobject("scripting.filesystemobject") if err then err.clear exit function end if thepath=replace(thepath,"\","/") if left(thepath,1)="/" then thepath=right(thepath,len(thepath)-1) end if if right(thepath,1)="/" then thepath=left(thepath,len(thepath)-1) end if thepatharray=split(thepath,"/") for i=0 to ubound(thepatharray) createfoldersub1=createfoldersub1&thepatharray(i)&"/" createfoldersub=server.mappath(createfoldersub1) if not fsofo.folderexists(createfoldersub) then fsofo.createfolder(createfoldersub) end if next if err then err.clear else binfo=true end if createit=binfo end function
下面的是通過正則實(shí)現(xiàn)
'============================== ''創(chuàng)建文件目錄(多層) ''使用正則 '============================== Function Create_N_Folder(save, ByVal Path) Dim Fso Set Fso = Server.CreateObject("Scripting.FileSystemObject") If Not Fso.FolderExists(Path) Then Dim regEx Set regEx = New RegExp regEx.Pattern = "^(.*)\\([^\\]*)$" regEx.Global = False regEx.IgnoreCase = True save = save & regEx.Replace(Path, "$2") & "|" Path = regEx.Replace(Path, "$1") If Create_N_Folder(save, Path) Then Create_N_Folder = True Set regEx = Nothing Else If save = "|" Then Create_N_Folder = True Else Dim Temp Temp = Mid(save, 2, Len(save) - 2) If InStrRev(Temp, "|") = 0 Then save = "|" Path = Path & "\" & Temp Else Dim Folder Folder = Mid(Temp, InStrRev(Temp, "|") + 1) save = "|" & Mid(Temp, 1, InStrRev(Temp, "|") - 1) & "|" Path = Path & "\" & Folder End If Fso.CreateFolder Path If Create_N_Folder(save, Path) Then Create_N_Folder = True End If End If Set Fso = Nothing End Function
以上就是asp中創(chuàng)建多級目錄的兩段代碼的詳細(xì)內(nèi)容,更多關(guān)于asp創(chuàng)建多級目錄的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Cookies 欺騙漏洞的防范方法(vbs+js 實(shí)現(xiàn))
考慮到 ASP 開發(fā)可以采用 vbs 和 js 兩種語言,這里同時提供兩種語言的程序代碼(雙語版?YY中……)2009-12-12ASP 日期的加減運(yùn)算實(shí)現(xiàn)代碼
今天在工作中遇到了一個問題,需要按時間查詢,可是查詢出來的結(jié)果顯示的不正確。2009-12-12ASP備份SQL Server數(shù)據(jù)庫改進(jìn)版
改進(jìn)的ASP備份SQL Server數(shù)據(jù)庫,網(wǎng)上原理的不是很好,需要的朋友可以參考下。2011-02-02ASP下使用Access數(shù)據(jù)庫需要注意的18條安全法則
ASP下使用Access數(shù)據(jù)庫需要注意的18條安全法則,注意了下面地方,基本上您的access數(shù)據(jù)庫就不容易被別人盜取了。2011-02-02ASP將Excel數(shù)據(jù)導(dǎo)入到SQLServer的實(shí)現(xiàn)代碼
ASP將Excel數(shù)據(jù)導(dǎo)入到SQLServer的代碼,有點(diǎn)亂,大家根據(jù)需要自己查找下。2010-04-04ASP中巧用Split()函數(shù)生成SQL查詢語句的實(shí)例
有時候我們需要根據(jù)參數(shù)來實(shí)現(xiàn)多種條件查詢,這里就是通過split函數(shù)將參數(shù)分割為多個2014-04-04asp下tag的實(shí)現(xiàn),簡單介紹與部分代碼
asp下tag的實(shí)現(xiàn),簡單介紹與部分代碼...2007-03-03