Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Base64 encoded string to file

I have a base64 encoded string.

How can I write this base64 encoded string to a file?

like image 329
JL. Avatar asked Oct 19 '09 12:10

JL.


People also ask

How do I decode a Base64 encoded file?

To decode a file with contents that are base64 encoded, you simply provide the path of the file with the --decode flag. As with encoding files, the output will be a very long string of the original file. You may want to output stdout directly to a file.

How do I get Base64 encoded strings?

In JavaScript there are two functions respectively for decoding and encoding Base64 strings: btoa() : creates a Base64-encoded ASCII string from a "string" of binary data ("btoa" should be read as "binary to ASCII"). atob() : decodes a Base64-encoded string("atob" should be read as "ASCII to binary").


2 Answers

Try this:

File.WriteAllBytes(@"c:\yourfile", Convert.FromBase64String(yourBase64String)); 
like image 102
Rubens Farias Avatar answered Oct 01 '22 10:10

Rubens Farias


As a first pointer, check out MSDN's documentation on the XmlTextreader's ReadBase64 Method... http://msdn.microsoft.com/en-us/library/system.xml.xmltextreader.readbase64.aspx

like image 45
flq Avatar answered Oct 01 '22 10:10

flq