C# Base64 String to PNG Image

Here’s how you can save a base64 encoded string to image file in C#. public void SaveImageFile(string filename, string base64Image) { string destinationImgPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + Constants.UserImagesPath+"\\"+filename+".png"; try { Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + Constants.UserImagesPath); } catch (IOException iox) { Console.WriteLine(iox.Message+" "+iox.Data); } var bytes = Convert.FromBase64String(base64Image); using (var imageFile = new FileStream(destinationImgPath, FileMode.Create)) { imageFile.Write(bytes, 0, bytes.Length); […]

Read More

How to get the Month Name in C#?

You can use the CultureInfo to get the month name. Another way is to use extension methods. Here is an example of how to do it using extension methods: Add a DateTimeExtensions class to your project. static class DateTimeExtensions { public static string ToMonthName(this DateTime dateTime) { return CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(dateTime.Month); } public static string ToShortMonthName(this DateTime […]

Read More