C# - BASE64 to Image

public void ConvertBase64ToImage(String strBASE64)
{
     String _outputFile = @"c:\temp\test.jpg";
     try
     {
        Byte[] _imageBytes = Convert.FromBase64String(strBASE64);

        MemoryStream ms = new MemoryStream(_imageBytes, 0, _imageBytes.Length);

        // Convert byte[] to Image
        ms.Write(_imageBytes, 0, _imageBytes.Length);
        Image _image = Image.FromStream(ms, true);

        _image.Save(_outputFile);
        MessageBox.Show("save image success");
     }
     catch (Exception ex)
     {
        MessageBox.Show(ex.Message);
     }

}

Popular posts from this blog

SAP CPI - Loop Process Call with SuccessFactor (oData V2)

Setting IntelliJ IDEA to run Groovy Script