Verify that the file exists and is deleted

Source: Internet
Author: User

' Parameter: File name (relative path)
Public Function Deleteafile (filepath)
If filepath = "" Or IsNull (filepath) Then Exit Function
Dim I,filesplit,temp,filename,fileextname,temppath
Filesplit = Split (filepath, "|")
On Error Resume Next
For i = 0 to UBound (filesplit)
temp = Server.MapPath (Filesplit (i))
Fileextname = Getfileextname (filepath) (1)
TempPath = Replace (temp, "." & Fileextname, "*." & Fileextname)
If ofso.fileexists (temp) Then ofso.deletefile (TempPath)
Next
If Err <> 0 Then Err.Clear
End Function

Dim Forumname,urlpath
Dim FSO
Forumname = Request.QueryString ("Oppara")
If forumname = "" Then lib.alerterror 3, "no form path specified",-1
URLPath = Request.QueryString ("Opurl")
If URLPath = "" Then lib.alerterror 3, "No file path specified",-1
Set fso = new Filelib
Response. Write (URLPath)
Call FSO. Deleteafile (URLPath)
%>
<script language= "JavaScript" >
if (opener.<% = Forumname%>.value!= "")
{
opener.<% = Forumname%>.value= "";
Alert ("The operation has been successfully removed, please proceed to the next step");
}
else {
Alert (' File not found, Operation terminated ');
}
Window.close ()
</script>
<%
Set FSO = Nothing
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.