Several useful functions in ASP

xiaoxiao2021-03-06  39

Function deletefile (filename) 'Delete file

IF filename <> "" "" "

SET FSO = Server.createObject ("scripting.filesystemObject")

If fso.fileexists (filename) THEN

Fso.deletefile filename

END IF

SET FSO = Nothing

END IF

END FUNCTION

Function CreateDir (Byval LocalPath) 'Creating a directory, if there is a multi-level directory, create a level first level

ON Error ResMe next

LocalPath = Replace (localpath, "/", "/")

Set fileObject = server.createObject ("scripting.filesystemObject")

Patharr = split (localpath, "/")

PATH_LEVEL = Ubound (Patharr)

For i = 0 to Path_level

IF i = 0 THEN PATHTMP = Patharr (0) & "/" Else Pathtmp = Pathtmp & Patharr (i) & "/"

CPath = Left (pathtmp, len (pathtmp) -1)

If not fileObject.folderexists (cpath) THEN fileObject.createfolder cpath

NEXT

SET fileObject = Nothing

IF Err.Number <> 0 THEN

CreateDir = false

Err.clear

Else

CreateDir = TRUE

END IF

END FUNCTION

Function Generandomb FileName (Byval SzFileName) The new random file name is generated according to the original file name

Randomize

Rannum = int (90000 * rND) 10000

If MONTH (NOW) <10 THEN C_MONTH = "0" & ​​Month (now) else c_month = month (now)

if Day (now) <10 THEN C_DAY = "0" & ​​day (now) else c_day = day (now)

IF Hour (now) <10 TEN C_HOUR = "0" & ​​HOUR (now) else c_Hour = Hour (now)

IF minute (now) <10 THEN C_MINUTE = "0" & ​​minute (now) else c_minute = minute (now)

If Second (now) <10 TEN C_SECOND = "0" & ​​Second (now) else c_second = minute (now)

FILEEXT_A = Split (SZFileName, ".")

FILEEXT = LCase (fileext_a (ubound (fileext_a)))

GENERATERANDOMFILENAME = Year (now) & c_month & c_day & c_Hour & C_Minute & C_Second & "&" & rannuM & "." & Fileextend function

Function Jaron_replace (strcontent, start_string, end_string, replace_string)

'CMS replacement function: Source string, front part, back part, replaceable characters

'Returns the replaced string

Jaron_replace = Replace (StrContent, STRCONTENT, INSTR (Str ", INSTR (STRCONTENT, END_STRING) LEN (End_String) -1), Replace_String)

END FUNCTION

Function ReplacePlus (strcontent, start_string, end_string, replace_string) 'Documentation, all characters between all start, end, end

ON Error ResMe next

Markcounts = Ubound (split (strcontent, start_string))

Prestring = strcontent

For i = 0 to Markcounts

Startmark = INSTR (1, PREString, Start_String, 1)

If Startmark = 0 Then Exit for

CompMark = INSTR (1, PREString, End_String, 1) LEN (End_String)

VERSTRING = MID (Prestring, Startmark, Compmark - Startmark)

Prestring = Replace (preString, Verstring, Replace_String)

NEXT

ReplacePlus = preString

if Err.Number <> 0 Then Err.Clear

END FUNCTION

If you don't know how many Flash inside, you want to remove them all. It can be used with this.

StrContent = ReplacePlus (strcontent, "", "")

This command can remove all .... of the HTML code all deleted

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

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