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) %>
ASP deletes files, you must use the server's FileSystemObject object
Create a delete file function:
'删除文件(适合所有文件) Function Deltextfile(fileurl)'参数为相对路径 Set objFSO = CreateObject("Scripting.FileSystemObject") fileurl = Server.MapPath(fileurl) if objFSO.FileExists(fileurl) then '检查文件是否存在 objFSO.DeleteFile(fileurl) end if Set objFSO = nothing End Function
2. Call the delete file function:
'删除网站根目录下的a.txt文件 Deltextfile "\a.txt"
[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!