Fonctions personnalisées couramment utilisées dans ASP pour gérer le téléchargement et la suppression des fichiers
<%
'' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '.
'Toutes les fonctions VBS personnalisées
'' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '.
fonction deletefile (nom de fichier) 'supprimer le fichier
Si le nom de fichier <> alors
Set fso = server.createObject (scripting.fileSystemObject)
Si fso.fileexists (nom de fichier) alors
nom de fichier fso.deletefile
terminer si
Définir FSO = rien
terminer si
fonction finale
'' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '.
Fonction Createdir (ByVal LocalPath) 'Le programme qui crée un répertoire. S'il y a plusieurs niveaux de répertoires, le crée un niveau à la fois
sur l'erreur reprendre ensuite
LocalPath = remplacer (localPath, /, /)
set fileObject = server.createObject (scripting.filesystemObject)
patharr = fendre (localPath, /)
path_level = ubund (patharr)
pour i = 0 à path_level
Si i = 0 alors pathtmp = patharr (0) & / else pathtmp = pathtmp & patharr (i) & /
cpath = gauche (pathtmp, len (pathtmp) -1)
Si non fileObject.Folderexists (cPath), alors fileObject.createFolder CPATH
suivant
set fileObject = rien
Si err.number <> 0 alors
CreateDir = false
err.Clear
autre
CreateDir = true
terminer si
fonction finale
'' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '.
fonction SaverandFileName (byval szfilename) 'générer un nouveau nom de fichier aléatoire basé sur le nom du fichier d'origine
randomiser
'rannum = int (90000 * rnd) +10000
'Si mois (maintenant) <10 alors c_month = 0 & mois (maintenant) else c_month = mois (maintenant)
'Si jour (maintenant) <10 alors c_day = 0 & day (maintenant) else c_day = jour (maintenant)
'Si heure (maintenant) <10 alors c_hour = 0 & hour (maintenant) else c_hour = hour (maintenant)
'Si minute (maintenant) <10 alors c_Minute = 0 & Minute (maintenant) else c_Minute = Minute (maintenant)
'Si deuxième (maintenant) <10 alors c_second = 0 & second (maintenant) else c_second = minute (maintenant)
FileExt_A = Split (SzFileName ,.)
fileExt = lCase (fileExt_a (ubund (fileExt_a)))
SaverandFileName = remplacer (remplacer (remplacer (maintenant ,:,), -,),) & int (10 * rnd) &. & FileExt
'GeneraterAndomFileName = Year (Now) & C_Month & C_Day & C_Hour & C_MUTITE & C_SECOND & RANNUM &. & Fileext
fonction finale
'' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '.
fonction Jaron_Replacer (StrContent, start_string, end_string, rechange_string)
'Fonction de remplacement CMS: chaîne source, première partie, dernière partie, caractères remplacés
'Renvoie la chaîne remplacée
Jaron_Replacer = Remplace (StrContent, Mid (StrContent, instr (strContent, start_string), instr (strContent, end_string) + len (end_string) -1), remplace_string)
fonction finale
'' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '.
fonction remplaceplus (strContent, start_string, end_string, replace_string)