Export (0) Print
Expand All

HttpResponse.BinaryWrite Method

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

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

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

instance.BinaryWrite(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.

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)
    

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

Community Additions

ADD
Show:
© 2014 Microsoft