Solved

MemoryStream Convert.ToBase64String

Posted on 2011-09-28
5
567 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

623 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