How to convert Binary into Text String with Base 64 Encoding in C# .NET Framework
Base 64 encoding is an important groundwork step required for many different tasks. This can be a bit tricky to set up, which can eat up your whole afternoon if you don’t have a good solution in mind. To take the guesswork out, I am going to be showing you how to get this done using an API, letting you finish up in but a few minutes.
First we need our package, so let’s install that with NuGet:
Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 3.2.8
Now we can proceed with our function call, which you can model after this example code:
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 EditTextBase64EncodeExample{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 Base64EncodeRequest(); // Base64EncodeRequest | Input requesttry{// Base 64 encode, convert binary or file data to a text stringBase64EncodeResponse result = apiInstance.EditTextBase64Encode(request);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling EditTextApi.EditTextBase64Encode: " + e.Message );}}}}
Finished.