Displaying Source Code(s)
|
|
Kill Statement
--------------------------------------------------------------------------------
Description : The Kill statement deletes files. The required
pathname argument must be absolute and include the drive letter.
This supports the use of the wildcard character * to delete
mulitple files.
example usage:
Deletes file.txt In directory New Folder off C drive's root.
<% Kill "C:New Folderfile.txt" %>
Deletes file.txt In directory New Folder off the server's root.
<% Kill Server.MapPath("/New Folder/file.txt") %>
Deletes all files In directory New Folder off the C drive's
root.
<% Kill "C:New Folder*" %>
Deletes all files In directory New Folder off the server's root.
<% Kill Server.MapPath("/New Folder") & "*" %>
source code:
<%
Private Sub Kill(ByVal pathname)
Dim objFSO, boolErr, strErrDesc
On Error Resume Next
Set objFSO = Server.CreateObject("scripting.filesystemobject")
objFSO.DeleteFile pathname
If Err Then
boolErr = True
strErrDesc = Err.description
End If
Set objFSO = Nothing
On Error GoTo 0
If boolErr Then Err.Raise 5102, "Kill Statement", strErrDesc
End Sub
%>
-------------------------------------------------------------------------------- |
|
|