Deleting File by using DeleteFile

We can delete a file by using File system object or FSO in Active Server Page ( ASP). We can delete the file by using DeleteFile object. We will use the same FSO and server Map Path to define the path of the file to be deleted.

Before applying the delete command we will be checking if the file is there or not by using file exist command.

Here is the code.

Dim OpenFileobj, FSOobj,FilePath
Set FSOobj = Server.CreateObject("Scripting.FileSystemObject")
if FSOobj.fileExists(FilePath) Then

Response.Write "file Exist"
Response.Write "<br>Deleted file "&FSOobj.DeleteFile(FilePath)
Response.Write "File does not exist"
End if
Set FSOobj = Nothing

We can check the file extension and use one if condition to delete only a particular type of file.

Be the first to post comment on this article :


Post Comment This is for short comments only. Use the forum for more discussions.

HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us
©2000-2015 All rights reserved worldwide Privacy Policy Disclaimer