WebRequest webRequest = WebRequest.Create("验证码url");
            WebResponse webResponse = webRequest.GetResponse();
            Stream stream = webResponse.GetResponseStream();
            string cookie = webResponse.Headers.Get("Set-Cookie");
            Image img = Bitmap.FromStream(stream);
            pictureBox1.Image = img;
            using (MemoryStream ms1 = new MemoryStream())
            {
                img.Save(ms1, System.Drawing.Imaging.ImageFormat.Jpeg);
                byte[] arr1 = new byte[ms1.Length];
                ms1.Position = 0;
                ms1.Read(arr1, 0, (int)ms1.Length);
                ms1.Close();
                textBox1.Text = Convert.ToBase64String(arr1);
            }

  因为要做验证码识别第三方接口对接 需要将图片转换为base64传递参数 记录一下

 

posted on 2017-10-05 10:11  xuelei被占用了  阅读(751)  评论(0编辑  收藏  举报