<%
Const ForReading = 1
Const TristateTrue = -1 'Unicode
Const FILE_TRANSFER_SIZE = 16384 '16k'Use the following line for IIS4/PWS - this is the default for IIS5
Response.Buffer = TrueFunction TransferFile(path, mimeType, filename)
Dim objFileSystem, objFile, objStream
Dim char
Dim sent
sent=0
TransferFile = TrueSet objFileSystem = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFileSystem.GetFile(Path)
Set objStream = objFile.OpenAsTextStream(ForReading, TristateTrue)Response.AddHeader "content-type", mimeType
response.AddHeader "Content-Disposition","attachment;filename="&filename 
Response.AddHeader "content-length", objFile.SizeDo While Not objStream.AtEndOfStream
char = objStream.Read(1)
Response.BinaryWrite(char)
sent = sent + 1
If (sent MOD FILE_TRANSFER_SIZE) = 0 Then
Response.Flush
If Not Response.IsClientConnected Then
TransferFile = False
Exit Do
End If
End If
LoopResponse.Flush
If Not Response.IsClientConnected Then TransferFile = FalseobjStream.Close
Set objStream = Nothing
Set objFileSystem = Nothing
End FunctionDim path, mimeType, successpath = "c:\test.txt" ' 自己在C:建立一个test.txt文件
mimeType = "application/x-msdownload" 
success = TransferFile(path, mimeType, "test.txt"
Response.End
%>
 

解决方案 »

  1.   

    zcflion(土匪):你写错地方了吧 :)
      

  2.   

    LOOK
      try    cn.Open;  except
        showmessage('错误源:'+cn.errors.Item[0].Get_Source
           +chr(10)+'描述:'+cn.errors.Item[0].Get_Description
           +chr(10)+'状态:'+cn.errors.Item[0].Get_SQLState
           +chr(10)+'错误代码:'+inttostr(cn.Errors.Item[0].Get_Number)
           +chr(10)+'NATIVE错误:'+inttostr(cn.Errors.Item[0].Get_NativeError)
            );    result:=false;
        cn.Close;
        exit;
      end;
    CN是ADOCONNECTION
      

  3.   

    To: jiaorg(jiaorg)这里不是ADOConnection,而是dbexpress
    根本就不产生例外!
    难道没有人知道吗?