Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 28th, 2006, 01:33 PM
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
  #2 (permalink)  
Old December 29th, 2006, 11:29 AM
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

Doesn't matter. I've changed the BLOB to CLOB. Also I found out that a 100 byte array fields was 137 array fields when converted.. So the example on MSDN must be flawed.

 - mega
Moving to C# .NET


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert byte[] to hex value gunjan.sh C# 2005 4 January 24th, 2008 05:15 AM
Big challenge here! How to convert char* to char^? samiswt Visual C++ 2005 1 November 30th, 2007 09:09 PM
convert byte[] to hex wkm1925 C# 1 December 14th, 2006 09:07 PM
Convert a char to int!!!!?? vtvb C++ Programming 6 March 18th, 2006 05:51 AM
convert byte to bitmap jlzmut C# 2 December 18th, 2005 05:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.