File Deletion

<% strdelete = Request.QueryString("delete") strFN = Request.QueryString("FN") strFT = Request.QueryString("file") 'display the SHOW-ME-THE-FILE screen If strdelete = "Show" Then If strFT = "image" Then Response.Write "



" Response.Write "Delete? " Response.Write "List Files

" Else Response.Write "

" & strFN & "

" Response.Write "Delete? " Response.Write "List Files

" End If Response.End End If 'display the ARE-YOU-SURE screen If strdelete = "Sure" Then If strFT = "image" Then Response.Write "



" Response.Write "Are You Sure You Want To Delete This File?
" Response.Write "Yes, Delete It. " Response.Write "NO, Do Not Delete It!

" Else Response.Write "

" & strFN & "

" Response.Write "Are You Sure You Want To Delete This File?
" Response.Write "Yes, Delete It. " Response.Write "NO, Do Not Delete It!

" End If Response.End End If 'call the delete function If strdelete = "Yes" Then Call functionDF() End If 'the delete function Sub functionDF() Dim fso, f1 Set fso = CreateObject("Scripting.FileSystemObject") Set f1 = fso.GetFile(Server.MapPath(strFN)) f1.Delete Response.Write "

File " & strFN & " Deleted!

" Response.Write "Return To List

" Response.End End Sub 'view files in this directory dirtowalk = "./" 'display the files Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder(Server.MapPath(dirtowalk)) Set fc = f.Files Response.Write "
" Response.Write "

File List

" For Each tobdel In fc 'dont display this page If tobdel.name = "default.asp" Then Response.Write "" 'is the file an image? ElseIf Right(tobdel.name, 4) = ".jpg" Then Response.Write "View " Response.Write "Del " & tobdel.name & "

" ElseIf Right(tobdel.name, 4) = ".gif" Then Response.Write "View " Response.Write "Del " & tobdel.name & "

" ElseIf Right(tobdel.name, 4) = "jpeg" Then Response.Write "View " Response.Write "Del " & tobdel.name & "

" '...or another file type Else Response.Write "View " Response.Write "Del " & tobdel.name & "

" End If Next %>