MemoryStream Convert.ToBase64String

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

ZURINETAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
wdosanjosConnect With a Mentor Commented:
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
 
wdosanjosCommented:
Base 64 is used to represent binary data as a string not the other way around.  Please clarify.
0
 
ZURINETAuthor Commented:
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
 
ZURINETAuthor Commented:
Answer not complete
0
 
wdosanjosCommented:
Hi ZURINET,

What's missing?

Regards.
0
All Courses

From novice to tech pro — start learning today.