HttpResponse.BinaryWrite(Byte[]) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将二进制字符串写入 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)