The ASP File.Delete Method is used to delete a particular file or folder from a system.
Syntax
FileObject.Delete[(force)]
FileObject.Delete[(force)]
Parameter Values:
- 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 1: Below code illustrates the ASP File.Delete Method.
<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.GetFile("d:\GFG.txt")
f.Delete
response.write("GFG.txt file is deleted")
set f=nothing
set fs=nothing
%>
Output:
GFG.txt file is deleted
Example-2: Below code demonstrates the ASP folder.delete Method.
<%
dim fs,fo
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fo=fs.GetFolder("d:\GFG")
fo.Delete
set fo=nothing
set fs=nothing
%>
Output:
GFG Folder is deleted