您现在的位置是:网站首页> 编程资料编程资料
asp判断某个文件是否存在的函数_应用技巧_
2023-05-25
270人已围观
简介 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 ifASP判断文件是否存在以及删除文件实例代码
<% '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文件是否存在内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
相关内容
- ASP+ajax实现顶一下、踩一下同支持与反对的实现代码_应用技巧_
- ASP删除img标签的style属性只保留src的正则函数_应用技巧_
- asp中将字符串转数字的函数小结_应用技巧_
- ASP将数字转中文数字(大写金额)的函数_应用技巧_
- asp限制域名访问实现代码_应用技巧_
- asp程序执行数据库的效率提升建议_应用技巧_
- asp createTextFile生成文本文件支持utf8_应用技巧_
- ASP中RecordSet Open和Connection.Execute一些区别与细节分享_应用技巧_
- set rs=conn.execute,set rs=server.createobject(“ADODB.recordset”)的性能对比_应用技巧_
- 完美的ASP分页脚本代码_应用技巧_
