asp判定某个文件是否存在的函数

最近在写成果的时候需要判定某个文件是否存在,存在则挪用,不存在则动态显示页面的成果,用到了下面的代码,特分享一下需要的伴侣可以参考一下。

两个函数都是基于ASP中的FileSystemObject工具,也就是FSO,写成函数利便今后利用。

ASP查抄目次是否存在的函数代码

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 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

asp中判定文件是否存在(不是本机上的文件)

用fso.fileexists只能查询当地文件是否存在,用组件xmlhttp的readyState的要领可以获取长途文件是否存在,返回大于0,暗示文件存在,不然,就是不存在。

set XMLHTTP =Server.CreateObject("Microsoft.XMLHTTP") XMLHTTP.open("HEAD","http://www.test.com/test.htm",false) XMLHTTP.send() if XMLHTTP.status=200 then '文件存在 end if

ASP判定文件是否存在以及删除文件实例代码

<% 'ASP判定文件是否存在以及删除文件实例代码 dim htmlFilefs htmlFile="../book_show.html" htmlFile=server.MapPath(htmlFile) Set fs=Server.CreateObject("Scripting.FileSystemObject") If fs.FileExists(htmlFile) Then '判定文件是否存在 fs.DeleteFile htmlFile,true '假如文件存在,则删除文件 end if Set fs=Nothing %>

到此这篇关于asp判定某个文件是否存在的函数的文章就先容到这了,更多相关asp文件是否存在内容请搜索剧本之家以前的文章或继承欣赏下面的相关文章但愿各人今后多多支持剧本之家!

您大概感乐趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wsdffz.html