共用方式為


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)
    

適用於