欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp判斷某個(gè)文件是否存在的函數(shù)

 更新時(shí)間:2020年09月15日 00:05:09   投稿:mdxy-dxy  
最近在寫(xiě)功能的時(shí)候需要判斷某個(gè)文件是否存在,存在則調(diào)用,不存在則動(dòng)態(tài)顯示頁(yè)面的功能,用到了下面的代碼,特分享一下需要的朋友可以參考一下

最近在寫(xiě)功能的時(shí)候需要判斷某個(gè)文件是否存在,存在則調(diào)用,不存在則動(dòng)態(tài)顯示頁(yè)面的功能,用到了下面的代碼,特分享一下需要的朋友可以參考一下。

兩個(gè)函數(shù)都是基于ASP中的FileSystemObject對(duì)象,也就是FSO,寫(xiě)成函數(shù)方便以后使用。

ASP檢查目錄是否存在的函數(shù)代碼

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檢查文件是否存在的函數(shù)代碼

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中判斷文件是否存在(不是本機(jī)上的文件)

用fso.fileexists只能查詢(xún)本地文件是否存在,用組件xmlhttp的readyState的方法可以獲取遠(yuǎn)程文件是否存在,返回大于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判斷文件是否存在以及刪除文件實(shí)例代碼

<%
'ASP判斷文件是否存在以及刪除文件實(shí)例代碼
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
%>

到此這篇關(guān)于asp判斷某個(gè)文件是否存在的函數(shù)的文章就介紹到這了,更多相關(guān)asp文件是否存在內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論