需要引用

using System.Drawing;
using System.Drawing.Imaging;

方法:

 protected string Base64StringToImage(string base64string)
        {
            try
            {
                int len = base64string.IndexOf("base64,");
                base64string= base64string.Substring(len + 7, strbase64.Length - 7 - len)+ ".jpg";

                string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + (new Random().Next(1000, 9999));

                byte[] bt = Convert.FromBase64String(base64string);
                System.IO.MemoryStream stream = new System.IO.MemoryStream(bt);
                Bitmap bitmap = new Bitmap(stream);
                bitmap.Save(Server.MapPath("/Content/SaveImage/" + fileName), ImageFormat.Jpeg);

                //释放资源
                bitmap.Dispose();
                stream.Close();
                return fileName;
            }
            catch (Exception ex)
            {
                return ex.Message;
            }

        }