SQL PHP HTML ASP JavaScript articles and free scripts to download

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
FilePath=Server.MapPath("images/myfile.asp")
Set FSOobj = Server.CreateObject("Scripting.FileSystemObject")
if FSOobj.fileExists(FilePath) Then

Response.Write "file Exist"
Response.Write "<br>Deleted file "&FSOobj.DeleteFile(FilePath)
Else
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 :


Google+

Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



Join Our Email List
Email:  
For Email Newsletters you can trust
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer