ASP检查指定目录和文件是否存在asp
ASP检查指定目录和文件是否存在...
以下为两个自写的ASP函数,第一个函数CheckDir,用于判断所指定的文件夹是否存在,也就是目录是否存在;第二个函数CheckFile用于检查指定文件是否存在在于某个目录中。
两个函数都是基于ASP中的FileSystemObject对象,也就是FSO,写成函数方便以后使用。
ASP检查目录是否存在的函数代码
Function CheckDir(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
ASP检查文件是否存在的函数代码
Function CheckFile(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
上一篇:ASP的中文日期转换函数
下一篇:ASP截取字符串函数可判断汉字
最新评论
热门推荐
我要评论