实现代码一、比较专业看起来
'============================== '创建多级目录,可以创建不存在的根目录 '参数:要创建的目录名称,可以是多级 '创建目录的根目录从当前目录开始 '''调用举例 ''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
上面的是循环
实现方法二、
'自动创建多极目录 '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
下面的是通过正则实现
'============================== ''创建文件目录(多层) ''使用正则 '============================== 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中创建多级目录的两段代码的详细内容,更多关于asp创建多级目录的资料请关注其它相关文章!
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
更新日志
2024年11月20日
2024年11月20日
- 群星《我们的歌第六季 第1期》[FLAC/分轨][456.01MB]
- 齐秦 《辉煌30年DSD》24K珍藏版2CD[WAV+CUE][1.9G]
- 张玮伽《聆听伽音 HQCDII 》[正版原抓WAV+CUE][1.1G]
- 阿杜2002《天黑》台湾首版 [WAV+CUE][1.2G]
- 关淑怡.2019-Psychoacoustics(金曲重绎)(24BIT)【FLAC】
- 米线《醉迷声线6N纯银SQCD》【WAV+CUE】
- 刘紫玲2024《清平调》[低速原抓WAV+CUE]
- 伍佰1998《世界第一等》98绝版收藏EP[WAV+CUE]
- 天乐试机天碟 《终极参考SACD》十大发烧唱片之一[WAV分轨]
- 群星《新说唱2024 第12期 (下)》[320K/MP3][95.27MB]
- 楼兰2024-《楼兰传奇》[低速原抓WAV+CUE]
- 楼兰《楼兰传奇2》2024[低速原抓WAV+CUE]
- 陈果《有了你》UPM24K金碟[日本限量版][WAV+CUE]
- 群星《新说唱2024 第12期 (下)》[FLAC/分轨][506.43MB]
- 李常超 (Lao乾妈)《天生江湖》[320K/MP3][168.84MB]