間違った新しいWebmaster Webサイトをテストするときに正常に使用できるコードを共有し、マルチレベルディレクトリの作成をサポートします
コード1
function createmultifolder(byval cfolder)dim objfso、phcreatefolder、createfolderarray、createfolder dim i、ii、createfoldersub、blinfo blinfo = false createfolder = cfolder on er ersume resume resume resume resume objfso exit function end if right(createfolder、1)= "/" then createfolder = left(createfolder、len(createfolder)-1)end end exte次のphcreatefoldersub = server.mappath(createfoldersub)objfso.folderexists(phcreatefoldersub)then objfso.createfolder(phcreatefoldersub)end if if if err.clear()else blinfo = true end if createmultifolder = blinfo end enduction機能
使い方:
createmultifolder( "/202003/tools/")
コード2、テストOK
「JB51 ReterryFunction CreateIT(Path)Dim FSofo、The Patharraydim I、II、binfobinfo = falsethepath = pathset fsofo = create object( "scripting.filesystemobject)の場合、clearexit ifthepath = clearexit versunted ifthepath ="/"/"/"/"/"/"/"/"/"/"/"/"/"/"/"/"左(the path、1)= "/" the path = right(the path、len(the path)-1)end ifif right(the path、1)= "/" thenthepath = left(the path、len(the path)-1)end ifthepatharray = split( "/")i = 0 to ubund(thepatharray)createfoldersub1 = createfoldersub1&thepatharray(i)& "/" createfoldersub = server.mappath(createfoldersub1) ifcreateit = binfoend関数
テストコード
createit( "/202004/tools/")
上記のコードを実行できない場合は、IIS実行ユーザーの権限に書き込み関数があるかどうかを確認してください。今日のテスト中、デフォルトのIIS7.5を実行できません。
次の実装コードは簡単で、学習に適しています
フォルダが存在するかどうかを検出する方法は? If it does not exist, it will automatically create folder=server.mappath("/imagess")Set fso = CreateObject("Scripting.FileSystemObject")if fso.fileexists(Server.mappath(filepath)) thenrespnse.write("What else can be built after all")elsefso.createfolder(folder)end ifSet fso = nothingDim objFSOSet objfso = server.createObject( "Scripting.filesystemObject")if objfso.folderexists(server.mappath(savepath))= false theonobjfso.createfolder(server.mappath(savepath))end ifffolder = server.maptath( "/images")set fso = fsobject decreated f.ipting f.dipting dipting dipting dipting dipting dipting dipting dipting dipting dipting dipting fso.fileexists(server.mappath(filepath))thenrespnse.write( "他に何が構築できるか")elsefso.createfolder(folder)end ifset fso = nothing