HttpResponse.BinaryWrite(Byte[]) 方法

定义

将二进制字符串写入 HTTP 输出流。

public:
 void BinaryWrite(cli::array <System::Byte> ^ buffer);
public void BinaryWrite (byte[] buffer);
member this.BinaryWrite : byte[] -> unit
Public Sub BinaryWrite (buffer As Byte())

参数

buffer
Byte[]

要写入输出流的字节。

示例

以下示例将文本文件读入缓冲区,并将缓冲区写入 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);

Dim MyFileStream As FileStream
 Dim FileSize As Long
 
 MyFileStream = New FileStream("sometext.txt", FileMode.Open)
 FileSize = MyFileStream.Length
 
 Dim Buffer(CInt(FileSize)) As Byte
 MyFileStream.Read(Buffer, 0, CInt(FileSize))
 MyFileStream.Close()
 
 Response.Write("<b>File Contents: </b>")
 Response.BinaryWrite(Buffer)
    

适用于