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

asp用fso检测文件是否存在并删除的源代码

asp利用fso 来判断文件是否存在的方法  

<html>

<body>删除一个文件的范例<br><br>   

  <%   
      Dim   objFSO         '声明一个名称为   objFSO   的变量以存放对象实例   
      Set   objFSO   =   Server.CreateObject("Scripting.FileSystemObject")   
        If   objFSO.FileExists(Server.MapPath("\zzzyk.com\test.asp"))   Then   
            objFSO.DeleteFile   Server.MapPath("\zzzyk.com\test.asp"),True   
            Response.Write   "已经成功地对文件"&Server.MapPath("\zzzyk.com\test.asp")&"进行了删除"   
        Else   
            Response.Write   Server.MapPath("\zzzyk.com\test.asp")&"不存在,无法进行删除"   
        End   If   
      Set   objFSO   =   Nothing             '释放   FileSystemObject   对象实例内存空间   
  %>   

  </body>

</html>


CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,