A set of FSO related function, commonly used code (also asked frequently, repeated questions)

Source: Internet
Author: User
Tags date copy
fso| Delete Files repeatedly
<%
' |>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>> Aspwizard Copyright 1999-2001 >>>>>>>
' |>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>[Generic File Deletion]&GT;&GT;&GT;&GT;&GT;&GT;&GT;&GT;&GT;&GT;&GT;&GT;&GT;&GT;&G T;>
'| Author:joaquim Jos? Prates Ferreira
'| Date created:13/01/2001
'| Last update:28/06/2001
'| Dependencies:
'| description:this function would delete unwanted files from the server ...
'| v1.1:added a new parameter [Intshowlabel] 0-do not show LABEL/1-show label
'| V1.0:this function only accepts one parameter at the moment, the path with the file,
'| Below there are examples the "how to" call the function.
' |e.g.
'| Call Generic_filedeletion (File path ' REQUIRED ')
'| Call Generic_filedeletion ("MyFile.txt")
'| Call Generic_filedeletion ("Win95/myfile.txt")
'|
'| Please remember to specify a Path, otherwise a Error would occur ...

Function Generic_filedeletion (ByVal strpath,byval Intshowlabel)

' ERROR CHECKING!!!! ...
IF strpath = "" or IsNull (strpath) Then
Response.Write ("Sorry but a path is required when calling this function")
Response.End
End IF

' ERROR CHECKING!!!! ...
IF Intshowlabel = "" or IsNull (Intshowlabel) Then
Response.Write ("Sorry but" paramter <b>intShowLabel</b> is missing. PARAMETER is REQUIRED ")
Response.End
End IF

Filename = Server.MapPath (strpath)

Set fs = CreateObject ("Scripting.FileSystemObject")

If FS. FileExists (filename) Then
Fs. DeleteFile (filename)

If Intshowlabel = 1 Then
Response.Write "File" & "<b> (" & strpath & ") </b>" & "has Been Deleted with success.<br& gt; "
End If
Else
Response.Write "No path is found, or file does not exist to delete...<br>"
End If

End Function
%>





Copy file


<%
' |>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>> ASPWizard.co.uk Copyright 1999-2001 >>>>>>>>>>> >>>>>>
' |>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>[generic_filecopy.asp]&GT;&GT;&GT;&GT;&GT;&GT;&GT;&GT;&GT;&GT;&GT;&GT;&GT;&GT;&G T;>
'| Author:joaquim Jos? Prates Ferreira
'| Last Author:joaquim Jos? Prates Ferreira
'| Date created:26/04/2001
'| Last update:26/04/2001
'| Dependencies:
'| description:this function would copy Files from [A] to [B]
'| V1.0:this function would copy a file from one Folder to another.
'|
'| Parameters:
'| Strfilesource-we specify the path to the file to Copy
'| Strfiledestination-we sepcify The path to the new file
'| Stroverwrite-we say if We want to overwright a file
'|
'| e.g:
'| Call Generic_filecopy ("D:\Xkudos\NewsX_1997.mdb", "D:\Xkudos\Xkudos\Xkudos\DB\NewsX_1997.mdb", True)
Function generic_filecopy (ByVal strfilesource,byval strfiledestination,byval stroverwrite)
'--------------------------------[ERROR CHECKING]--------------------------------
' ERROR CHECKING!!!! ...
IF Strfilesource = "" or IsNull (Strfilesource) Then
Response.Write ("Sorry but a File Source path is required when calling this function")
Response.End
End IF
' ERROR CHECKING!!!! ...
IF strfiledestination = "" or IsNull (strfiledestination) Then
Response.Write ("Sorry but a File destination path is required while calling this function")
Response.End
End IF
' ERROR CHECKING!!!! ... [True-false]
IF stroverwrite = "" or IsNull (stroverwrite) Then
Response.Write ("Sorry but a File destination path is required while calling this function")
Response.End
End IF
'--------------------------------[/error checking]--



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.