FSO common code (delete, write, copy file function)

xiaoxiao2021-03-06  73

-----------------Delete Files-------------------

<%

'' | 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 An Error Will Occur ...

Function generic_filedeeletion (Byval Strpath, Byval IntshowLabel)

'' Error Checking !!!! ...

If strpath = "" or isnull (strpath) THEN

Response.write ("Sorry Butt Is Required When Calling this function")

Response.end

END IF

'' Error Checking !!!! ...

If IntshowLabel = "" or isnull (intShowLabel) THEN

Response.write ("Sorry But The Paramter IntshowLabel is missing. Parameter is required")

Response.end

END IF

FileName = Server.mappath (StrPath)

Set fs = creteObject ("scripting.filesystemobject")

IF fs.fileexists (filename) THEN

fs.deletefile (filename)

IF IntshowLabel = 1 THEN

Response.write "File" & " (" & StrPath & ") " & "HAS Been Deleted with success"

END IF

Else

Response.write "No Path Was Found, OR File Does Not Exist To Delete ...
"

END IF

END FUNCTION

%>

--------------- Copy Document ------------------

<%

'' | 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 Stroverwrite)

'' -------------------------------- [Error Checking] ------------ ------------------- '' Error Checking !!!! ...

If strfilesource = "" or isnull (strfilesource) THEN

Response.write ("Sorry Butt Source Path Is Required When Calling this function")

Response.end

END IF

'' Error Checking !!!! ...

If StrfileDestination = "" or isnull (strfiledstination) THEN

Response.write ("Sorry Butt Destination Path Is Required When Calling this function")

Response.end

END IF

'' Error Checking !!!! ... [True - False]

If StroverWrite = "" or isnull (stroverwrite) THEN

Response.write ("Sorry Butt Destination Path Is Required When Calling this function")

Response.end

END IF

'' -------------------------------- [/ error checking] ----------- ---------------------

SET FSO = CreateObject ("scripting.filesystemObject")

If fso.fileexists (strfilesource) then

Fso.copyFile Strfilesource, StrfileDestination, StroverWrite

Else

Response.write ("The File Does Not Exist ...")

Response.end

END IF

SET FSO = Nothing

END FUNCTION

%>

----------------- Write the file ----------------

<%

'' | Example of Call:

'' | Call Generic_FileWriter ("MyFileName", "HTML", "The Content Goes Here ..."

Function generic_filewriter (strfilename, strfileextension, strfilecontent)

Set ofs = creteObject ("scripting.filesystemobject")

Set OTXS = OFS.OpenTextFile (Server.Mappath (StrfileName & "." & Strfileextension, 8, true)

OTXS.WRITELINE (STRFILECONTENT)

OTXS.Close

END FUNCTION

%> ----------------- Bole -----------------------

<%

'' | EXAMPLE:

'' | Call Fileferret (StrDirectory, DtstartingDate, DtendingDate, INTQUED)

'' | Normal USAge:

'| Call Fileferret ("/ Desktop / asp_odds / generic_funcs / test /", "19/02/2001 00:00:00", "20/02/2001 16:16:34", 0)

'' | WHEN USING ON Queued Directory:

'| Call Fileferret ("/ desktop / asp_odds / generic_funcs / test /", "19/02/2001 00:00:00", "20/02/2001 16:16:34", 1)

Function Fileferret (Byval DTStartingDate, ByVal Dtendingdate, Byval IntQued)

DIM INTBADCOUNTER '' IT WILL Count How Many Bad Emails There Are

DIM INTQUEDCOUNTER

INTBADCOUNTER = 0

INTQUEDCOUNTER = 0

'' ----------------------- [Start Error Checking] -------------------- -------

'' Checks if there is a (directory) Defined in the parameter

If strdirectory = "" or isnull (strdirectory) THEN

Response.write ("The Parameter for Directory Is Missing - IT IS A Required Parameter!")

Response.end

END IF

'' CHECKS IF THE (Starting Date) Parameter Is Missing

IF dtstartingdate = "" or isnull (dtstartingdate) THEN

Response.write ("The Starting Date Parameter Is Missing - IT IS A Required Parameter!")

Response.end

END IF

'' Checks if the (ending date) Parameter is Missing

If DtendingDate = "" or isnull (DtendingDate) THEN

Response.write ("The ending date parameter is missing - it is a required parameter!")

Response.end

END IF

'' Checks if the (intqueD) parameter is missingif intques = "" or isnull (intqued) THEN

Response.write ("The Intqued Parameter is Missing - IT IS A Required Parameter!")

Response.end

END IF

'' ----------------------- [End Error Checking] -------------------- -------

Set fs = creteObject ("scripting.filesystemobject")

Set f = fs.getfolder (server.mappath (strdirectory))

Set fc = f.files

%>

<% = strdirectory%>


<%

For Each File in FC

INTQUEDCOUNTER = INTQUEDCOUNTER 1

'' It Checks if it is in between a CERTAIN TIME LIMITE

IF formatdatetime (file.datecreated, 0)> = dtstartingdate and formatdatetime (file.datecreated, 0) <= DtendingDate Then

'' CHECKS IF IT IS AN Email

If Right (file.name, 4) = ".msg" or right (file.name, 4) = ".eml" THEN

IMG = "img / email.gif"

END IF

'' Checks if it is a log file or a Text File

If Right (File.Name, 4) = ".log" or right (file.name, 4) = ".txt" then

IMG = "img / txt.jpg"

END IF

'' CHECKS IF IS A BAD Email File

IF right (file.name, 4) = ".bad" then

'' Increas the bad emails counter by 1

INTBADCOUNTER = INTBADCOUNTER 1

IMG = "img / emailbad.gif"

END IF

%>

<% = File.name%>

<% = formatdatetime (file.datecreated, 0)%>

<%

END IF

NEXT

%>

There <% = INTBADCOUNTER%> Bad emails.

<%

'' WE CHECK IF WE Using The Queue Directory (0 - NO / 1 - YES)

IF intqued = 1 THEN%>

There <% = intquedcounter%> emails awning to be sample.

<% End if%>

<%

END FUNCTION

%>

转载请注明原文地址:https://www.9cbs.com/read-108356.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.047, SQL: 9