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

首頁 > 編程 > ASP > 正文

ASP如何檢測某文件夾是否存在,不存在則自動創建

2024-05-04 11:03:17
字體:
來源:轉載
供稿:網友

直接給大家分享一下錯新站長站測試正常可以使用的代碼,并且支持多級目錄創建

代碼一

 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

使用方法:

CreateMultiFolder("/202003/tools/")

代碼二、測試ok

'自動創建多極目錄'code by jb51 reterryfunction createit(path)dim fsofo,cinfo,thepath,thepatharraydim i,ii,binfobinfo=falsethepath=pathset fsofo=createobject("scripting.filesystemobject")if err thenerr.clearexit functionend ifthepath=replace(thepath,"/","/")if left(thepath,1)="/" thenthepath=right(thepath,len(thepath)-1)end ifif right(thepath,1)="/" thenthepath=left(thepath,len(thepath)-1)end ifthepatharray=split(thepath,"/")for i=0 to ubound(thepatharray)createfoldersub1=createfoldersub1&thepatharray(i)&"/"createfoldersub=server.mappath(createfoldersub1)if not fsofo.folderexists(createfoldersub) thenfsofo.createfolder(createfoldersub)end ifnextif err thenerr.clearelsebinfo=trueend ifcreateit=binfoend function

測試代碼

createit("/202004/tools/")

以上代碼如果無法運行,請檢查iis運行用戶的權限是否有寫功能。今天測試的時候默認iis7.5下是無法運行的。

下面的實現代碼功能性簡單,適合學習

ASP如何檢測某文件夾是否存在,不存在則自動創建folder=server.mappath("/imagess") Set fso = CreateObject("Scripting.FileSystemObject") if fso.fileexists(Server.mappath(filepath)) then respnse.write("都有了還建什么建") else fso.createfolder(folder) end if Set fso = nothingDim objFSO Set objFSO = Server.CreateObject("Scripting.FileSystemObject") If objFSO.FolderExists(Server.MapPath(SavePath))=false Then objFSO.CreateFolder(Server.MapPath(SavePath)) End Iffolder=server.mappath("/imagess") Set fso = CreateObject("Scripting.FileSystemObject") if fso.fileexists(Server.mappath(filepath)) then respnse.write("都有了還建什么建") else fso.createfolder(folder) end if Set fso = nothing              
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 蒙自县| 锦州市| 河津市| 文安县| 时尚| 曲松县| 乐至县| 防城港市| 汝州市| 河池市| 建始县| 且末县| 航空| 繁峙县| 巴林右旗| 齐齐哈尔市| 徐水县| 锡林郭勒盟| 巴马| 龙里县| 绍兴市| 芦山县| 湖口县| 华坪县| 吐鲁番市| 盱眙县| 新绛县| 井陉县| 克东县| 普兰店市| 宜黄县| 大悟县| 如东县| 康保县| 南丰县| 林周县| 岚皋县| 关岭| 宝应县| 汝南县| 庆城县|