日期:2014-05-17 浏览次数:21043 次
Function TransferFile(ByRef oStream, sMimeType, sFilename) Dim iChar, iSent, iSize Dim c Const FILE_TRANSFER_SIZE = 32768 '32k iSent = 0 TransferFile = True iSize = oStream.Size With Response .Charset = "GB2312" .ContentType= sMimeType .AddHeader "Accept-Ranges", "bytes" .AddHeader "Content-Length", iSize .AddHeader "Content-Type", sMimeType .AddHeader "DownloadOptions", "noopen" .AddHeader "Content-Disposition","attachment; filename=" & sFilename End With c = 0 Do While c <= iSize iChar = oStream.ReadBin(FILE_TRANSFER_SIZE) c = c + FILE_TRANSFER_SIZE With Response .BinaryWrite(iChar) iSent = iSent + FILE_TRANSFER_SIZE If (iSent MOD FILE_TRANSFER_SIZE) = 0 Then .Flush If Not .IsClientConnected Then TransferFile = False Exit Do End If End If End With Loop Response.Flush If Not Response.IsClientConnected Then TransferFile = False Set oStream = Nothing End Function