ASP采集入库生成本地文件的几个函数

'*****************************************************************
' function
' 作用 :利用流保存文件
' 参数 :from(远程文件地址),tofile(保存文件位置)
'*****************************************************************
Private Function SaveFiles(byref from,byref tofile)
Dim Datas
Datas=GetData(from,0)
Response.Write "保存成功:"&formatnumber(len(Datas)/1024*2,2)&"Kb"
response.Flush
if formatnumber(len(Datas)/1024*2,2)>1 then
ADOS.Type = 1
ADOS.Mode =3
ADOS.Open
ADOS.write Datas
ADOS.SaveToFile server.mappath(tofile),2
ADOS.Close()
else
Response.Write "保存失败:文件大小"&formatnumber(len(imgs)/1024*2,2)&"Kb,小于1K"
response.Flush
end if
end function

'*****************************************************************
' function(私有)
' 作用 :利用fso检测文件是否存在,存在返回true,不存在返回false
' 参数 :filespes(文件位置)
'*****************************************************************
Private Function IsExists(byref filespec) 
If (FSO.FileExists(server.MapPath(filespec))) Then
IsExists = True
Else
IsExists = False
End If
End Function

'*****************************************************************
' function(私有)
' 作用 :利用fso检测文件夹是否存在,存在返回true,不存在返回false
' 参数 :folder(文件夹位置)
'*****************************************************************
Private Function IsFolder(byref Folder)
If FSO.FolderExists(server.MapPath(Folder)) Then 
IsFolder = True
Else
IsFolder = False
End If
End Function

'*****************************************************************
' function(私有)
' 作用 :利用fso创建文件夹
' 参数 :fldr(文件夹位置)
'*****************************************************************
Private Function CreateFolder(byref fldr) 
Dim f
Set f = FSO.CreateFolder(Server.MapPath(fldr))
CreateFolder = f.Path
Set f=nothing
End Function

'*****************************************************************
' function(公有)
' 作用 :保存文件,并自动创建多级文件夹
' 参数 :fromurl(远程文件地址),tofiles (保存位置)
'*****************************************************************
Public Function SaveData(byref FromUrl,byref ToFiles)
ToFiles=trim(Replace(ToFiles,"//","/"))
flName=ToFiles
fldr=""
If IsExists(flName)=false then 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/3412.html