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