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 / ASP.NET / Web Services / May 2005

Tip: Looking for answers? Try searching our database.

Parsing Base64 encoding

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LP - 02 May 2005 22:22 GMT
A web service returns base64 encoded data. The goal is to parse it and store
it into binary file with .dat extension. This file is then will be used by a
custom program to produce diagrams. As far as I know base64 data is not any
known graphic format, from what I understand it's just encoded stream of
bytes. Which I need to write to .dat file. Where to start? any links or
suggestions?

Thank you.
Bruce Wood - 02 May 2005 23:30 GMT
Have you tried this?

Declare the element in question in the XML schema for the Web Service
as being "base64Binary".

Load the results of the Web Service call into a DataSet. The resulting
DataColumn should have a type of Byte and the byte array it contains
should be the binary version of the base 64 encoding in the XML.

Failing that, I did write my own base64 encoding class that I could
pass along.
laimis - 02 May 2005 23:34 GMT
If you care just saving the bytes into the file, use FileStream class
provided by .net. It provides a Write method that accepts a byte array
as a parameter (byte array would be your base64 data).

If you need to decode base64 encoded data, simple use
Convert.ToBase64String() method which is also provided by the framework.
base64 is nothing special, just bytes which values are limited by the
set of characters that belong to base64 encoding.

Does that answer your question?
laimis - 02 May 2005 23:36 GMT
If you care just saving the bytes into the file, use FileStream class
provided by .net. It provides a Write method that accepts a byte array
as a parameter (byte array would be your base64 data).

If you need to decode base64 encoded data, simple use
Convert.ToBase64String() method which is also provided by the framework.
base64 is nothing special, just bytes which values are limited by the
set of characters that belong to base64 encoding.

Does that answer your question?
Joshua Flanagan - 03 May 2005 03:40 GMT
As the other posters have hinted at, you just need to use the Convert
class and a way to write the data to disk (FileStream works nicely).

Assuming your base64 data is in a string named receivedBase64string, and
you want to write it to the file c:\received.data

using System.IO;

byte[] rawData = Convert.FromBase64String(receivedBase64string);
using (FileStream fs = new FileStream(
      @"c:\received.dat",
      FileMode.Create))) {
  fs.Write(rawData, 0, rawData.Length);
}

Joshua Flanagan
http://flimflan.com/blog

> A web service returns base64 encoded data. The goal is to parse it and store
> it into binary file with .dat extension. This file is then will be used by a
[quoted text clipped - 4 lines]
>
> Thank you.
LP - 03 May 2005 14:37 GMT
That's easier than I thought, thanks everyone!

> As the other posters have hinted at, you just need to use the Convert
> class and a way to write the data to disk (FileStream works nicely).
[quoted text clipped - 22 lines]
> >
> > Thank you.

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.