Difference between revisions of "Base64-Encoding"
From Updox API
(Created page with "Code samples for base-64 encoding a file in order to attach it to an API call... {| class="wikitable" style="width:900px; vertical-align:top; align:left" ! Language || Source...") |
Latest revision as of 11:33, 5 December 2013
Code samples for base-64 encoding a file in order to attach it to an API call...
Language | Source Code Examples |
---|---|
Java | File file = new File("c:\filename.ext"); byte[] bytes = loadFile(file); byte[] encoded = Base64.encodeBase64(bytes); String encodedString = new String(encoded); |
C# |
byte[] xmlDataByteArray; System.IO.FileStream inFile; inFile = new FileStream("C:\\filename.ext", FileMode.Open, FileAccess.Read); xmlDataByteArray = new byte[inFile.Length]; long bytesRead = inFile.Read(xmlDataByteArray, 0, Convert.ToInt32(inFile.Length)); inFile.Close(); String strBase64 = Convert.ToBase64String(xmlDataByteArray, 0, xmlDataByteArray.Length); |