Convert Byte array to Base64 Char Array : Encode « File Stream « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » File Stream » EncodeScreenshots 
Convert Byte array to Base64 Char Array
Convert Byte array to Base64 Char Array


using System;
using System.IO;

class Test {
    public static void Main() {
        // The size of the char[] must 
        // be at least 4/3 the size of the source byte[] and must be 
        // divisible by 4.
        byte[] data = 0x010x020x5A0xFF0x00xF00x4D0x620x78,  
            0xD20xC50xA10x5A0xD60x0C0xA90xA60x630x3D0xC2
            0xD50x0F0xCC0x010xF20x0C};

        char[] base64data =  new char[(int)(Math.Ceiling((double)data.Length / 34)];

        Console.WriteLine("\nByte array encoding/decoding");
        Convert.ToBase64CharArray(data, 0, data.Length, base64data, 0);
        Console.WriteLine(new String(base64data));
    }
}

           
       
Related examples in the same category
1.Encoding in actionEncoding in action
2.Encoding: Unicode ASCII GetBytes GetString
3.Encoding.ASCII.GetString
4.Encoding.BigEndianUnicode.GetString
5.Encoding.URF8/Unicode/UTF32/.GetBytes
6.Encoding.URF8/Unicode/UTF32/GetString
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.