<%
class filemanage
  


'检查文件夹是否存在
public Function checkfolder(FullPath)
dim fso0
Set fso0=  CreateObject("Scripting.FileSystemObject")
If fso0.FolderExists(FullPath) then
checkfolder = True
Else
checkfolder = False
End if
Set fso0= nothing
End Function

'删除文件夹  
Public  Function Deletefolder(FullPath)
 dim fso
 if checkfolder(FullPath) then
     Set fso = CreateObject("Scripting.FileSystemObject")
     fso.DeleteFolder FullPath
     Set fso = nothing
 end if
End Function

'新建文件夹
Public  Function createfolder(FullPath)
        dim fso,temp_path
  set   fso=server.CreateObject   ("scripting.filesystemobject")   
        temp_path=server.MapPath(fullpath)
        if   checkfolder(temp_path)=false   then     
              fso.CreateFolder(temp_path)   
        end   if   
  set   fso=nothing   
End Function



'◆检查某一文件是否存在
'=========================================================
public Function Checkfile(filePath)
dim fso0
'filePath=Server.MapPath(".")&"\"&filePath
Set fso0=  CreateObject("Scripting.FileSystemObject")
If fso0.fileExists(filePath) then
Checkfile = True
Else
Checkfile = False
End if
Set fso0= nothing
End Function

'删除文件  
Public  Function DeleteFile(FullPath)
 dim fso
 if Checkfile(FullPath) then
     Set fso = CreateObject("Scripting.FileSystemObject")
     fso.DeleteFile FullPath
     Set fso = nothing
 end if
End Function


'文件下载
public function downloadFile(strFile) '下载文件
  dim strfilename,s,fso,f,intFilelength
 strFilename = server.MapPath(strFile)
 
 Response.Buffer = True
 Response.Clear
 
 Set s = Server.CreateObject("ADODB.Stream")
 s.Open
 
 s.Type = 1
 
 on error resume next
 
 Set fso = Server.CreateObject("Scripting.FileSystemObject")
 if not fso.FileExists(strFilename) then
  Response.Write("<h1>Error:</h1>" & strFilename & " 此文件未找到！<p>")
  Response.End
 end if
 
 Set f = fso.GetFile(strFilename)
 intFilelength = f.size
 
 s.LoadFromFile(strFilename)
 if err then
  Response.Write("<h1>Error: </h1>" & err.Description & "<p>")
  Response.End
 end if
 
 Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name
 Response.AddHeader "Content-Length", intFilelength
 Response.CharSet = "UTF-8"
 Response.ContentType = "application/octet-stream"
 
 Dim DataPart, PartSize,BytesRead
 BytesRead = 0
 
 Do While BytesRead < intFilelength
 
  PartSize = 64 * 1024
  if PartSize + BytesRead > intFilelength Then PartSize = intFilelength - BytesRead
  DataPart = s.Read(PartSize)
  BytesRead = BytesRead + PartSize
  Response.BinaryWrite(DataPart)
  Response.Flush
 Loop
 
 
 s.Close
 Set s = Nothing
 
End Function 





end class
%>