The implementation code is as follows:
Using System;
Using System. Collections. Generic;
Using System. ComponentModel;
Using System. Data;
Using System. Drawing;
Using System. Text;
Using System. Windows. Forms;
Using CodeClassLibrary;
Using System. IO;
Using System. Net;
Namespace ValidatorCodeDemo
{
Public partial class frmValidatorCode: Form
{
Public frmValidatorCode ()
{
InitializeComponent ();
This. GetCode ();
}
Private void btnRefresh_Click (object sender, EventArgs e)
{
This. GetCode ();
}
/// <Summary>
/// Generate a new verification code
/// </Summary>
Private void GetCode ()
{
Try
{
HttpWebRequest request = (HttpWebRequest) WebRequest. Create ("http://checkcode.taobao.com/auction/checkcode? SessionID = eb3f99fbe975258ea87bc24c235ab24f & r = 1237173457015 ");
Stream responseStream = (HttpWebResponse) request. GetResponse (). GetResponseStream ();
Image original = Image. FromStream (responseStream );
Bitmap bitMap = new Bitmap (original );
This. pBoxCode. Image = bitMap; // Note: replace it with your PictureBox Control name.
ResponseStream. Close ();
}
Catch (Exception exception)
{
MessageBox. Show ("ERROR:" + exception. Message );
}
}
}
}