Advertisement
1_2002 Files #112348

deletefiles

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.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
<html><head>
<title>delte a file</title>
</head><body>
<center><H2>WARNING</H2></center>
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 
environment.
<p>For help or comments, feel free to contact me at <a href="mailto:[email protected]">Hotmail</a> 
or visit my temporary site at <a href="http://www22.brinkster.com/jbuck">www22.brinkster.com/jbuck</a>
<p>
Click on any file below to delete it. I recommend adding a few junk files for demostration
purposes.<p>

<%

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 <b>" & strFN & "</b><br>"
  Set f1 = fso.GetFile(Server.MapPath(strFN))
  f1.Delete
  
  Response.Write "All done!<br>"
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 "<a href='deletefiles.asp?delete=Yes&FN=" & tobdel.name & "'>"
    response.write tobdel.name & "</a></br>"

Next
%>
</body></html>
Original Comments (3)
Recovered from Wayback Machine