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:
void BinaryWrite (
	array<unsigned char>^ buffer
)
public void BinaryWrite (
	byte[] buffer
)
public function BinaryWrite (
	buffer : byte[]
)
Not applicable.

Parameters

buffer

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.

No code example is currently available or this language may not be supported.
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));
myFileStream.Close();

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

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))
myFileStream.Close()

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


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
Show: