Tuesday, June 17, 2025

How to convert bytes to base64string in c#

using fileupload control

 Convert.ToBase64String(fileUpload1.FileBytes);


using memory stream

 Stream fs = fileUpload1.PostedFile.InputStream;

        BinaryReader br = new BinaryReader(fs);

        

        Byte[] bytes = br.ReadBytes((int)fs.Length);

 Convert.ToBase64String(bytes );



base64 string meaning

the upper- and lower-case Roman alphabet characters (A–Z, a–z), the numerals (0–9), and the "+" and "/" symbols, with the "=" symbol as a special suffix code



No comments:

Post a Comment