Solved

MemoryStream Convert.ToBase64String

Posted on 2011-09-28
5
557 Views
Last Modified: 2012-05-12
Hallo
Need to convert a string to  base64 stream
any Idea..?
see code below

Thanks
StreamReader reader = new StreamReader(@"C:\Inetpub\ftproot\100.xml");
string parseInvResult = reader.ReadToEnd();
byte[] binaryData 
using (MemoryStream basePdfMemStream = new MemoryStream(Convert.ToBase64String(parseInvResult)))
				{
					binaryData = basePdfMemStream.ToArray();
				}

Open in new window

0
Comment
Question by:ZURINET
  • 3
  • 2
5 Comments
 
LVL 23

Expert Comment

by:wdosanjos
ID: 36719697
Base 64 is used to represent binary data as a string not the other way around.  Please clarify.
0
 

Author Comment

by:ZURINET
ID: 36719775
Hi wdosanjos

I have a need to provide base64 string for the datatype

byte[] Data;

in any XML file..

I have an xml document; I need to convert to base64 and insert it in into another xml document
i.e soap body  element.. defined as base64

what should be the best approach?

0
 
LVL 23

Accepted Solution

by:
wdosanjos earned 500 total points
ID: 36719878
When dealing with XML files, generally you don't need to convert to base64 manually as the XML classes will do that for you.  So, I believe the following should be enough.

StreamReader reader = new StreamReader(@"C:\Inetpub\ftproot\100.xml");
string parseInvResult = reader.ReadToEnd();
byte[] binaryData = System.Text.Encoding.UTF8.GetBytes(parseInvResult);

Open in new window

0
 

Author Closing Comment

by:ZURINET
ID: 36814959
Answer not complete
0
 
LVL 23

Expert Comment

by:wdosanjos
ID: 36815047
Hi ZURINET,

What's missing?

Regards.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question