Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Byte array example

Status
Not open for further replies.

Terpsfan

Programmer
Dec 8, 2000
954
US
I am trying to convert a VB.NET code example over to C# regarding a byte array. This is to export a crystal report to PDF using an exporttostream method. This is how it looks in VB.NET.

Code:
Dim st as System.IO.Stream
st = invoiceDoc1.ExportToStream(ExportFormatType.PortableDocFormat)

Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"

*****line below is where I am having the problem converting to C#
Dim b(st.Length) As Byte
*********************************************************
st.Read(b,0,st.Length)

Response.BinaryWrite(b)
Response.End()
 
Answer:
Dim b(st.Length) As Byte ==>
Byte[] b = new Byte[st.Length];
-obislavu-

 
Thanks, that put me on the right track but wasn't the exactly right answer. This is what I had to do to make it work.

Code:
byte[] b = new byte[st.Length];

//I had to also cast this as an integer
st.Read(b,0,(int)st.Length);

Now it works, and thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top