请教asp中response.binarywrite函数的用法。
发布网友
发布时间:2022-05-05 01:27
我来回答
共1个回答
热心网友
时间:2022-06-28 05:13
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("<b>File Contents: </b>");
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