• 企业400电话
  • 网络优化推广
  • AI电话机器人
  • 呼叫中心
  • 全 部 栏 目

    网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    ASP检查文件与目录是否存在的函数代码
    POST TIME:2021-10-18 06:55

    以下为两个自写的ASP函数,第一个函数CheckDir,用于判断所指定的文件夹是否存在,也就是目录是否存在;第二个函数CheckFile用于检查指定文件是否存在在于某个目录中。

    两个函数都是基于ASP中的FileSystemObject对象,也就是FSO,写成函数方便以后使用。

    ASP检查目录是否存在的函数代码

    Function CheckDir(Byval FolderPath)
    dim fso
    folderpath=Server.MapPath(".")"\"folderpath
    Set fso = Server.CreateObject("Scripting.FileSystemObject")
    If fso.FolderExists(FolderPath) then
    '存在
        CheckDir = True
    Else
    '不存在
        CheckDir = False
    End if
    Set fso = nothing
    End Function

    Function isExistFolder(Byval folderDir)
    	on error resume next
    	If objFso.FolderExists(server.MapPath(folderDir)) Then isExistFolder=True Else isExistFolder=False
    	if err then err.clear:isExistFolder=False
    End Function

    ASP检查文件是否存在的函数代码

    Function CheckFile(Byval FilePath) '检查某一文件是否存在
      Dim fso
      Filepath=Server.MapPath(FilePath)
      Set fso = Server.CreateObject("Scripting.FileSystemObject")
      If fso.FileExists(FilePath) then
      '存在
          CheckFile = True
      Else
      '不存在
          CheckFile = False
      End if
      Set fso = nothing
    End Function

    Function isExistFile(Byval fileDir)
    	on error resume next
    	If (objFso.FileExists(server.MapPath(fileDir))) Then isExistFile=True Else isExistFile=False
    	if err then err.clear:isExistFile=False
    End Function

    下面是其他网友的补充

    '================================================== 
    '函数名: CheckFile 
    '作 用:检查某一文件是否存在 
    '参 数:FileName ------ 文件地址 如:/swf/1.swf 
    '返回值:False ---- True 
    '================================================== 
      Public Function CheckFile(FileName) 
         On Error Resume Next 
         Dim FsoObj 
         Set FsoObj = Server.CreateObject("Scripting.FileSystemObject") 
         If Not FsoObj.FileExists(Server.MapPath(FileName)) Then 
           CheckFile = False 
           Exit Function 
         End If 
         CheckFile = True:Set FsoObj = Nothing 
      End Function
    

    到此这篇关于ASP检查文件与目录是否存在的函数代码的文章就介绍到这了,更多相关asp文件是否存在内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

    您可能感兴趣的文章:
    • ASP如何检测某文件夹是否存在,不存在则自动创建
    • asp 判断上传文件中是否存在危险代码
    • asp判断某个文件是否存在的函数
    上一篇:ReplaceTrim 函数之asp实现过滤掉字符中所有的tab和回车和换行的代码
    下一篇:SaveRemoteFile函数之asp实现保存远程的文件到本地的代码
  • 相关文章
  • 

    关于我们 | 付款方式 | 荣誉资质 | 业务提交 | 代理合作


    © 2016-2020 巨人网络通讯

    时间:9:00-21:00 (节假日不休)

    地址:江苏信息产业基地11号楼四层

    《增值电信业务经营许可证》 苏B2-20120278

    X

    截屏,微信识别二维码

    微信号:veteran88

    (点击微信号复制,添加好友)

     打开微信