ASP Is Fun

Learning ASP
Free Course
Basics
Functions
SQL Commands
Sample Code

Servers / Setup
Host Reviews
Server Setup
Error Tips

Contract ASP
Development

Intro to ASP



 
French Wedding


DeleteFile - Deleting a File



You should be very cautious in using this function, because it allows an ASP script to permanently delete a file from your server's hard drive.

As you might imagine, there are actually many important applications for this. If you let clients load up ads onto your server, and then delete a client from your system, you can use DeleteFile to remove all those ad graphics. If you create online postcards, DeleteFile can let you sweep out the old ones each month.

Really, only two lines are necessary for this function:

Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
ScriptObject.DeleteFile(filename)

You do of course have to set the "filename" variable to be a valid filename! :) You can either hard code this to be a certain file if you know what file will be deleted, you can take it as input from a form, or you can loop through a sequence of known values (if for example you named your postcards post1.html, post2.html, post3.html, etc).

Be VERY cautious that you never just let this function take in any file name at all. Hackers could then easily send in important file names and destroy your website.

ASP File Function List


ASP Main Page | ASP Ebooks | Free ASP Course | Contact Lisa
All content copyright © 2008 Minerva WebWorks LLC. All rights reserved.

Italian Wedding


Free Newsletter!

Ebooks
Intro to ASP
ASP SQL DB
Members
Shopping


Introduction to ASP

Romance Tips
Irish Romance
Italian Romance
French Romance

ASP Poll
How do you handle 500 errors?
I don't
Page does nothing
Displays error
Emails error