How can ASP delete a specified file under a specified folder? Don't worry, let's take a look at an ASP deltextfile delete the specified file instance under the specified folder tutorial
1.xls and 1.xls under folder Pic_1
Clear the folder with the following code:
<%dim pathsub 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 to delete files, you must use the server's FileSystemObject object
To create a delete file function:
' Delete file (for all files) ' Function deltextfile (fileurl) ' parameter is relative path Set objFSO = CreateObject ("Scripting.FileSystemObject") FileURL = Server.MapPath (fileurl) if Objfso.fileexists (fileurl) Then ' checks if the file exists objFSO.DeleteFile ( FileURL) End If Set objFSO = Nothing End Function
2. Call the Delete file function:
' Remove the A.txt file under the root of the Web site Deltextfile ' \a.txt '
"Recommended"
1. Share ASP FSO Delete file DeleteFile and folder DeleteFolder instance code
2. summarize the ASP FSO Tutorial--asp Delete method