Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / May 2005

Tip: Looking for answers? Try searching our database.

How do I convert a base64 encoded bytearray?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Litsegard - 25 May 2005 08:56 GMT
Hi!

I have a webservice which queries a table in SQLServer. The table has a
column, "Text", which is of datatype "image". When invoking the webmethod it
returns  dataset with the table included. The column is returned as a
base64binary as can be seen in the declaration excerpt below:

<xs:element name="text" type="xs:base64Binary" minOccurs="0" />

When I call the webservice and loops through the rows I see that the column
"text" is represented as a bytearray as well. What I'd like to do is to
convert this bytearray into an "ordinary" string. Please note that it must
work in a .Net Compact Framework environment. I've tried a number of
approaches but none has worked so I feel a little bit "lost in binary space".

Hope you can help me!
/Peter
Peter Litsegard - 25 May 2005 09:12 GMT
I forgot to mention that the data represented in the base64 bytearray is text
so what I want to do is to convert the text which is encoded in the base64
bytearray into a string.

Thanks again!
/Peter

> Hi!
>
[quoted text clipped - 13 lines]
> Hope you can help me!
> /Peter
Maqsood Ahmed - 25 May 2005 10:58 GMT
Hello,
You can use System.Text.Encoding.ASCII.GetString method to get string a
ASCII encoded string. see System.Text.Encoding class in MSDN for more
details.

HTH. Cheers.
Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net
Peter Litsegard - 25 May 2005 14:41 GMT
Hi Maqsood!

Thanks for your suggestion but I've tried that approach earlier with no
avail. Let me give you some more information:

When calling the webservice I get the following response (most of the
response removed for clarity):
<text>H4sIAAAAAAAAAM1Y23LbOBJ9nlTlH1B........</text>

As you can see the content of the base64 encoded bytestream contains a
base64 representation of the actual text. When I use your suggestion I get a
string alright but it is impossible to read. I think the problem is that the
.GetString method doesn't work with base64 encoded byte arrays.

Thanks again!
/Peter

> Hello,
>  You can use System.Text.Encoding.ASCII.GetString method to get string a
[quoted text clipped - 7 lines]
>
> *** Sent via Developersdex http://www.developersdex.com ***

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.