怎么判断"F:\doc\?/.txt"是错误的文件路径呢?

foodbed 2002-07-03 12:23:47
:)
...全文
30 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
huayuxing 2002-07-03
  • 打赏
  • 举报
回复
上面的太烦了,用fso的not fileexists(文件名)就可以了
julyclyde 2002-07-03
  • 打赏
  • 举报
回复
那不行吧?那个似乎遇到错误格式的文件名会出错
ChinaOk 2002-07-03
  • 打赏
  • 举报
回复
function procCheckFile(sName)
dim sExt,sPath,i,errorchar
errorchar=array("'","""","\","/","*","?","&","|","<",">")
procCheckFile="ok"
sPath=left(sName,instrRev(sName,"/"))
sPath=procCheckDir(sPath,1)
if sPath<>"ok" then
procCheckFile=sPath
exit function
end if
if not fo.FileExists(Server.MapPath(sName)) then
procCheckFile="文件没有找到!"
exit function
end if
else
for i=0 to ubound(errorchar)
if instr(sName,errorchar(i))>0 then
procCheckFile="文件名中含有非法字符!"
exit function
end if
next
end if
procCheckFile="ok"
end function

function procCheckDir(sPath,mode)
dim errorchar,i,hd,str
sPath=lcase(sPath)
procCheckDir="ok"
errorchar=array("'","""","\","..","//","*","?","&","|","<",">")
if isempty(sPath) or trim(sPath)="" then
procCheckDir="目录不能为空!"
exit function
end if
for i=0 to ubound(errorchar)
if instr(sPath,errorchar(i))>0 then
procCheckDir="目录名中含有非法字符"
exit function
end if
next


if mode=0 then exit function
if not fo.FolderExists(Server.MapPath(sPath)) then
procCheckDir="目录"&sPath&"没有找到!"
exit function
end if

end function
%>

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧