Using system;
Using system.drawing;
Using system.collections;
Using system.componentmodel;
Using system.windows.forms;
Using system.data;
Using system.net;
Using system.text;
Using system.io;
Summary description of Namespace BanyiWeb {///
Public Form1 () {// // Windows Form Designer Support for // InitializeComponent ();
// // TOD Add any constructor code after INITIALIZEComponent call //}
///
#REGION Windows Form Designer The code ///
/// summary> private void InitializeComponent () {System.Resources.ResourceManager resources = new System.Resources.ResourceManager (typeof (Form1)); this.label1 = new System.Windows.Forms.Label (); this. textBoxWeb = new System.Windows.Forms.TextBox (); this.button1 = new System.Windows.Forms.Button (); this.statusBar1 = new System.Windows.Forms.StatusBar (); this.richTextBox1 = new System. Windows.forms.richtextbox (); this.suspendlayout (); // // label1 // this.label1.location = new system.drawing.point (0, 16); this.Label1.name = "label1"; this .label1.size = new system.drawing.size (72, 16); this.label1.tabindex = 0; this.label1.text = "Please enter the URL:"; /// TEXTBOXWEB / / THIS.TEXTBOXWEB.LOCATION = new system.drawing.point (80, 8); this.textBoxWeb.name = "textBoxWeb"; this.textBoxWeb.Size = new system.drawing.size (248, 21); this.textBoxWeb.TabINDEX = 1; this .TextBoxWeb.Text = "http: // www."; /// Button1 // this.button1.location = new sys Tem.drawing.Point (344, 8); this.button1.name = "button1"; this.button1.size = new system.drawing.size (56, 20); this.button1.tabindex = 2; this.button1 .Text = "Submit"; this.button1.click = new system.EventHandler (this.button1_click); //// statusbar1 // this.statusbar1.Location = new system.drawing.point (0, 351); this .statusbar1.name = "statusbar1"; this.statusbar1.size = new system.drawing.size (416, 22); this.statusbar1.tabindex = 5; this.statusbar1.text = "http://www.banyi. COM / TXXL BY: BANYI ";
// // richTextBox1 // this.richTextBox1.Location = new System.Drawing.Point (0, 32); this.richTextBox1.Name = "richTextBox1"; this.richTextBox1.Size = new System.Drawing.Size (416, 320); this.richtextBox1.tabindex = 6; this.richtextBox1.text = "Please enter the URL correctly, slower when the program is not found,"; /// // Form1 // this.autoscale = false; this .Autoscalebasesize = new system.drawing.size (6, 14); this.clientsize = new system.drawing.size (416, 373); this.controls.add (this.richtextbox1); this.controls.add (this. Statusbar1); this.controls.add (this.button1); this.controls.add (this.TextBoxWeb); this.controls.add (this.label1); this.icon = ((System.drawing.icon) (Resources .GetObject ("$ this.icon"))))); this.name = "form1"; this.text = "Web source code"; this.ResumeLayout (false);} #ENDREGION
///
Private void button1_click (object sender, system.eventArgs e) {string WebStr; Webstr = textBoxWeb.Text; if (Webstr.Indexof ("http:") <0) {MessageBox.show ("Error Banyi", "You Enter wrong URL "); textBoxWeb.Text =" http: // www "; return;} button1.Enabled = false; HttpWebResponse res; HttpWebRequest req; try {req = (HttpWebRequest) WebRequest.Create (webstr); res. = (Httpwebresponse) Req.getResponse ();} catch (exception) {MessageBox.show ("Error Can't find this URL"); button1.enabled = true; return;} textBoxWeb.Text = " reading in .... "; StreamReader strm = new StreamReader (res.GetResponseStream (), Encoding.GetEncoding (54936)); // Simplified Chinese Encoding.GetEncoding (54936), Encoding.ASCII String sLine; richTextBox1.Text = ""; Do // learning notes do loop C # do while cycler loop {sline = strm.readline (); richtextbox1.text = richtextbox1.text sline;} while (sline! = Null); Strm.close (); textBoxweb.text = "http: // www."; button1.enabled = true;}}} This is another change Code problem. This will be available in Chinese Encoding.Getencoding (54936)