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:
// 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);
According to MSDN 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