日期:2009-10-25  浏览次数:20877 次

ASP 中处理文件上传以及删除时常用的自定义函数:

<%

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'所有自定义的VBS函数

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

function DeleteFile(Filename) '删除文件

if Filename<>"" then

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) '建立目录的程序,如果有多级目录,则一级一级的创建

on error resume 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