asp Deltextfile deletes the specified file in the specified folder instance tutorial

零下一度
Release: 2017-05-22 14:29:52
Original
2088 people have browsed it

How can asp delete the specified files in the specified folder? Don't worry, let's take you through an asp Deltextfile tutorial on deleting specified files in a specified folder

There are 1.xls and 1.xls under the folder pic_1

Clear the folder, the code is as follows:

<%
dim path
Sub EmptyFolder(filespec) 
Dim fso 
Set fso = CreateObject("Scripting.FileSystemObject") 
fso.DeleteFolder(filespec) 
fso.CreateFolder(filespec) 
End Sub 
path=server.MapPath("/pic_1")
Emptyfolder(path)
%>
Copy after login

ASP deletes files, you must use the server's FileSystemObject object

Create a delete file function:

&#39;删除文件(适合所有文件) 
Function Deltextfile(fileurl)&#39;参数为相对路径 
 Set objFSO = CreateObject("Scripting.FileSystemObject") 
  fileurl = Server.MapPath(fileurl) 
  if objFSO.FileExists(fileurl) then &#39;检查文件是否存在 
   objFSO.DeleteFile(fileurl) 
  end if 
 Set objFSO = nothing 
End Function
Copy after login

2. Call the delete file function:

&#39;删除网站根目录下的a.txt文件
Deltextfile "\a.txt"
Copy after login

[Related recommendations]

1. Share asp fso delete file DeleteFile and folder DeleteFolder Example code

2. Summary asp fso tutorial--ASP Delete method

The above is the detailed content of asp Deltextfile deletes the specified file in the specified folder instance tutorial. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!