当前位置:编程学习 > asp >>

给大家帖个函数!检查当前目录下是否存在指定的文件,如果存在就重新命名。

答案:<%
  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")
%>

上一个:分解质因数(asp 分布递归法)原创
下一个:asp程序和php程序转换要注意的问题

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,