Search Tools Links Login


This ASP page is a maintenance tool of sorts. It first lists all of the files in the directory.
The links when pressed pass the file name back to the same page which calls a delete function that delete the file which was just clicked on.

Original Author: Jason Buck


passes a querystring delete=Yes to call the delete function and passes a querystring FN= the filename to be deleted.


This code uses the Filesystemobject, passes variables via a querystring, and use a for each loop.
Again, make sure you want to delete the file before clicking.


List of all files in the directory minus the deleted file.

Side Affects

Make sure you are clicking on the right file, because once you click on it, it is gone.

API Declarations

This code was written by Jason Buck for free distribution.


delte a file


This code is very dangerous. When loaded, clicking on any file on this page
will cause that file to be deleted. I have not put in a confirm delete page.
I recommend doing so if you are ever going to use this delete function in a production

For help or comments, feel free to contact me at Hotmail
or visit my temporary site at

Click on any file below to delete it. I recommend adding a few junk files for demostration


strdelete = request.querystring("delete")
strFN = request.querystring("FN")
if strdelete = "Yes" Then
call functionDF()
End if
Sub functionDF()
  Dim fso, f1
  Set fso = CreateObject("Scripting.FileSystemObject")
  Response.Write "Deleting file " & strFN & "
  Set f1 = fso.GetFile(Server.MapPath(strFN))
  Response.Write "All done!
End Sub
' the dot . below represents the current directory that this file is in.
' this file will only delete in its current directory. to delete in
' directories, you would have to add that to the tobdel portion which is the FN
' that is being passed.
dirtowalk = "."
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(server.mappath(dirtowalk))
Set fc = f.Files
For Each tobdel in fc
    response.write ""
    response.write & "



About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 90 times




No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.