Пример #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     this.Hide();
     LoginForm frm1 = new LoginForm();
     frm1.Show();
 }
Пример #2
0
        private void GetImagePersonPic(string url)
        {

            //            CookieContainer cookies = new CookieContainer();
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Accept = "*/*";
            request.Method = "GET";
            request.UserAgent = "Mozilla/5.0";

            request.CookieContainer = new CookieContainer();
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            MemoryStream ms = null;
            using (var stream = response.GetResponseStream())
            {
                Byte[] buffer = new Byte[response.ContentLength];
                int offset = 0, actuallyRead = 0;
                do
                {
                    actuallyRead = stream.Read(buffer, offset, buffer.Length - offset);
                    offset += actuallyRead;
                } while (actuallyRead > 0);
                ms = new MemoryStream(buffer);
            }
            response.Close();
            //            globals.cookies = request.CookieContainer;
            //            globals.strCookies = request.CookieContainer.GetCookieHeader(request.RequestUri);
            try
            {
                Image image = new Bitmap(ms, true);
                globals.personImage = image;
                pictureBox2.Image = image;
            }catch(Exception e)
            {
                MessageBox.Show("密码错误!");
                this.Hide();
                LoginForm frm = new LoginForm();
                frm.Show();

            }
            
        }