Code:
private string GenerateBase64(string PathFile) { string StrBase64 = null; System.IOFileStream inFile; byte[] binaryData; try { inFile = new System.IOFileStream(PathFile, System.IO.FileMode.Open, System.IO.FileAccess.Read); binaryData = new Byte[inFile.Length]; long bytesRead = inFile.Read(binaryData, 0, (int)inFile.Length); inFile.Close(); } catch (SystemException exp) { throw new Exception(exp.Message); } // Convert the binary input into Base64 UUEncoded output. try { StrBase64 = System.Convert.ToBase64String(binaryData, 0, binaryData.Length); } catch (SystemException exp) { throw new Exception(exp.Message); } return(StrBase64); }
Nessun commento:
Posta un commento