ASP檢查文件與目錄是否存在的函數(shù)代碼
以下為兩個(gè)自寫的ASP函數(shù),第一個(gè)函數(shù)CheckDir,用于判斷所指定的文件夾是否存在,也就是目錄是否存在;第二個(gè)函數(shù)CheckFile用于檢查指定文件是否存在在于某個(gè)目錄中。
兩個(gè)函數(shù)都是基于ASP中的FileSystemObject對(duì)象,也就是FSO,寫成函數(shù)方便以后使用。
ASP檢查目錄是否存在的函數(shù)代碼
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檢查文件是否存在的函數(shù)代碼
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
下面是其他網(wǎng)友的補(bǔ)充
'==================================================
'函數(shù)名: CheckFile
'作 用:檢查某一文件是否存在
'參 數(shù):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
到此這篇關(guān)于ASP檢查文件與目錄是否存在的函數(shù)代碼的文章就介紹到這了,更多相關(guān)asp文件是否存在內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
生成EAN13標(biāo)準(zhǔn)的條形碼的ASP代碼實(shí)例
生成EAN13標(biāo)準(zhǔn)的條形碼的ASP代碼實(shí)例...2007-10-10
asp中獲取當(dāng)前頁(yè)面的地址與參數(shù)的函數(shù)代碼
asp中獲取當(dāng)前頁(yè)面的地址與參數(shù)的函數(shù)代碼,經(jīng)常需要用得到,特整理下,方便需要的朋友。2011-01-01
asp下取得客戶端IP地址函數(shù) 轉(zhuǎn)換IP地址函數(shù)
asp下取得客戶端IP地址函數(shù) 轉(zhuǎn)換IP地址函數(shù)...2007-08-08
.Net core 的熱插拔機(jī)制的深入探索及卸載問題求救指南
這篇文章主要介紹了.Net core 的熱插拔機(jī)制的深入探索及卸載問題求救指南,本文給大家啊介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-11-11
ASP + Serv-u 實(shí)現(xiàn)FTP的代碼
ASP + Serv-u 實(shí)現(xiàn)FTP的代碼...2006-10-10
isnumeric檢測(cè)是否為數(shù)字類型的asp代碼
ASP判斷是否為數(shù)字通常用isnumeric()函數(shù),它的作用是判斷里面的參數(shù)表達(dá)式是不是數(shù)值2007-11-11

