网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的范文:

 

标题 asp自动创建文件夹
范文
    在asp操作文件中,遇到了创建多级文件夹,其实一级别的创建文件夹很简单,就fso(路径)即可,但是遇到了多级文件夹,这就得写函数来创建多级文件夹
    相关:php自动创建文件夹
    asp自动创建多级文件夹,当其中文件夹不存在时,自动创建文件夹.
    代码如下:
    <%@LANGUAGE = VBScript%>
    <%Option Explicit%>
    <%'asp版本自动创建文件夹
    Dim fso,fso_flag,base,path,i
    set fso = CreateObject("Scripting.FileSystemObject")
    If isobject(fso) Then
    fso_flag = True
    Else
    fso_flag = false
    End If'
    If not fso_flag Then response.write"不支持fso.",response.End()
    base = request.ServerVariables("APPL_PHYSICAL_PATH")'获取本地基本物理路径
    'asp自动创建文件夹函数开始
    Function createdir(path)
    Dim temp_path,temp_path_array '定义私有路径
    path = Replace(path,"\","/")
    ' response.write path
    If isnull(path) or path = "" Then
    createdir = False
    Exit Function
    End if
    If not fso.FolderExists(path) then
    '获取次级目录路径
    temp_path_array = Split(path,"/")
    For i = 0 To UBound(temp_path_array)-1
    temp_path = temp_path&temp_path_array(i)&"/"
    Next'
    temp_path = Left(temp_path,Len(temp_path)-1)'获取次级目录
    if createdir(temp_path) Then
    fso.CreateFolder (path)
    createdir = true
    End If
    else'www.forasp.cn
    createdir = true
    Exit Function
    End if
    End Function
    'asp创建多级文件夹函数完毕
    path = base&"a/b/c"'因为path获取站点物理路径最后包括"/",所以建立文件要以空开头,然后是文件夹名
    'response.write path
    If (createdir(path)) Then
    response.write "已经创建"
    Else
    response.write "创建失败"
    End if
    %>
随便看

 

在线学习网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/18 7:54:38