Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 578
  • Last Modified:

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

0
ZURINET
Asked:
ZURINET
  • 3
  • 2
1 Solution
 
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
 
wdosanjosCommented:
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
 
ZURINETAuthor Commented:
Answer not complete
0
 
wdosanjosCommented:
Hi ZURINET,

What's missing?

Regards.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now