请教asp中response.binarywrite函数的用法。

如题。我想知道这个函数的参数是什么?参数是什么数据类型?
2024-11-24 17:00:39
推荐回答(1个)
回答1:

HttpResponse..::.BinaryWrite 方法将一个二进制字符串写入 HTTP 输出流。

下面的示例将一个文本文件读入缓冲区,然后将该缓冲区写入 HTTP 输出流。

FileStream MyFileStream;
long FileSize;

MyFileStream = new FileStream("sometext.txt", FileMode.Open);
FileSize = MyFileStream.Length;

byte[] Buffer = new byte[(int)FileSize];
MyFileStream.Read(Buffer, 0, (int)FileSize);
MyFileStream.Close();

Response.Write("File Contents: ");
Response.BinaryWrite(Buffer);

asp文件下载改名

Response.ContentType = "application/x-msexcel"
Response.AddHeader "Content-Disposition","attachment; filename=aa.xls"
Const adTypeBinary = 1
Dim strFilePath

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile Trim(sfile)

Response.BinaryWrite objStream.Read

objStream.Close
Set objStream = Nothing
HttpResponse = true