ASP Deltextfile Delete the specified file instance under the specified folder tutorial

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.