This documentation is archived and is not being maintained.

HttpResponse.BinaryWrite Method

Writes a string of binary characters to the HTTP output stream.

Namespace: System.Web
Assembly: System.Web (in system.web.dll)

Public Sub BinaryWrite ( _
	buffer As Byte() _
Dim instance As HttpResponse
Dim buffer As Byte()

public void BinaryWrite (
	byte[] buffer
public function BinaryWrite (
	buffer : byte[]
Not applicable.



The bytes to write to the output stream.

The following example reads a text file into a buffer and writes the buffer to the HTTP output stream.

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))
 Response.Write("<b>File Contents: </b>")

FileStream myFileStream;
long fileSize;

myFileStream = new FileStream("sometext.txt", FileMode.Open);
fileSize = myFileStream.get_Length();

ubyte buffer[] = new ubyte[(int)(fileSize)];
myFileStream.Read(buffer, 0, (int)(fileSize));

get_Response().Write("<b>File Contents: </b>");

var myFileStream : FileStream
var fileSize : long

myFileStream = new FileStream("sometext.txt", FileMode.Open)
fileSize = myFileStream.Length

var buffer : Byte[] = new Byte[int(fileSize)]
myFileStream.Read(buffer, 0, int(fileSize))

Response.Write("<b>File Contents: </b>")

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0