检查当前目录下是否存在指定的文件,如果存在就重新命名
程序员文章站
2022-06-22 11:24:32
<%function judgefileexit(strfilename)dim objfso,objfile,objfjdim strfilepathdim blfjdim intflagi...
<%
function judgefileexit(strfilename)
dim objfso,objfile,objfj
dim strfilepath
dim blfj
dim intflag
intflag=0
set objfso=createobject("scripting.filesystemobject")
strfilepath=server.mappath("./")
if right(strfilepath,1)<>"/" or right(strfilepath,1)<>"" then
strfilepath=strfilepath&""
end if
blfj=objfso.fileexists(strfilepath&strfilename)
do while blfj=true
intflag=intflag+1
blfj=objfso.fileexists(strfilepath &intflag&strfilename)
loop
if intflag=0 then
judgefileexit= strfilename
else
judgefileexit=intflag&strfilename
end if
set objfso=nothing
end function
response.write judgefileexit("22.htm")
%>
function judgefileexit(strfilename)
dim objfso,objfile,objfj
dim strfilepath
dim blfj
dim intflag
intflag=0
set objfso=createobject("scripting.filesystemobject")
strfilepath=server.mappath("./")
if right(strfilepath,1)<>"/" or right(strfilepath,1)<>"" then
strfilepath=strfilepath&""
end if
blfj=objfso.fileexists(strfilepath&strfilename)
do while blfj=true
intflag=intflag+1
blfj=objfso.fileexists(strfilepath &intflag&strfilename)
loop
if intflag=0 then
judgefileexit= strfilename
else
judgefileexit=intflag&strfilename
end if
set objfso=nothing
end function
response.write judgefileexit("22.htm")
%>