Template:Convert file to base64-encoding using CSharp

From Updox API
Jump to: navigation, search
 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);