View Single Post
 
Old December 28th, 2006, 01:33 PM
mega mega is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen N, , Denmark.
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default Convert byte[] to char[]

Hi all!

I'm having problems with the ToBase64CharArray method of the Convert class. I have a ashx page that supposed to get a pdf file from db.
My code looks like this:
Code:
// get the pdf blob and write in to the http stream
byte[] bytePdf = (byte[])dal.OpenQueryScalar("GetContractInfo", contractParam);
char[] charPdf = new char[bytePdf.Length];
Convert.ToBase64CharArray(bytePdf, 0, bytePdf.Length, charPdf, 0,Base64FormattingOptions.None);
context.Response.Write(charPdf);
According to MSDNhttp://msdn2.microsoft.com/en-us/library/3d0e5t57.aspx it should be right, but I keep getting an ArgumentOutOfRange exception on offsetOut. I've tried to set charPdf[1000000] (bytePdf is 97665) but I still get the same exception.

Any pointers?

 - mega
Moving to C# .NET
__________________
- mega
Aspiring JavaScript Ninja