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)

public void BinaryWrite (
	byte[] buffer
)
public void BinaryWrite (
	byte[] buffer
)
public function BinaryWrite (
	buffer : byte[]
)

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.

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);
    

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 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft