Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
Previous Versions
.NET Framework 2.0
System.Web
HttpResponse Class
 BinaryWrite Method
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
.NET Framework Class Library
HttpResponse.BinaryWrite Method

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

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

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

instance.BinaryWrite(buffer)
C#
public void BinaryWrite (
    byte[] buffer
)
C++
public:
void BinaryWrite (
    array<unsigned char>^ buffer
)
J#
public void BinaryWrite (
    byte[] buffer
)
JScript
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.

Visual Basic
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)
    
C#
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);
    
J#
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);
JScript
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
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker