HttpResponse.BinaryWrite(Byte[]) 方法

定義

將二進位字元的字串寫入 HTTP 輸出資料流。

public void BinaryWrite (byte[] buffer);

參數

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);

適用於

產品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8