Open In App

ASP DeleteFile Method

Improve
Improve
Like Article
Like
Save
Share
Report

The ASP DeleteFile Method is used to delete one or more files from the server. It returns an error if we want to delete a non-existing file. 

Syntax:

FileSystemObject.DeleteFile(filename[,force])

Parameter Values:

  • filename: It specifies the name of the file which you want to delete.
  • force: It is an optional attribute. It contains a Boolean value which indicates that whether a read-only file will be deleted or not.  It set to true means that the read-only file will be deleted. False represents that the file will not be deleted.

Example: Below example demonstrates the DeleteFile Method. 

ASP




<%
dim fs
Set fs=Server.CreateObject("Scripting.FileSystemObject")
if fs.FileExists("c:\pictures\a.txt") then
response.write("Exist file ")
 fs.DeleteFile("c:\pictures\a.txt")
 response.write("is Deleted")
end if
set fs=nothing
%>


Output:

Exist file is Deleted

Last Updated : 02 Mar, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads