How to decode a Base 64 String into Binary Content in C# .NET Framework

Base 64 strings are an important element to be able to parse, but this task can be a challenge in C#, requiring many hours to solve manually. What you need is a simple means of creating binary content from input strings. That is exactly what I have here for you today, and it will be ready to go in just a few minutes time.

Our package installation comes first, so let’s use NuGet for that using the console:

Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 3.2.8

Now we can go ahead and call our function, as so:

using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;namespace Example{public class EditTextBase64DecodeExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new EditTextApi();var request = new Base64DecodeRequest(); // Base64DecodeRequest | Input requesttry{// Base 64 decode, convert base 64 string to binary contentBase64DecodeResponse result = apiInstance.EditTextBase64Decode(request);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling EditTextApi.EditTextBase64Decode: " + e.Message );}}}}

And you are officially done! Talk about easy.

Image for post
Image for post

Written by

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store