Private voidButton1_Click (Objectsender, EventArgs e) {WebClient WebClient=NewWebClient (); WebClient. Proxy=NULL; WebClient. Encoding=Encoding.UTF8; Richtextbox1.appendtext (WebClient. Downloadstring (TextBox1.Text.Trim ())); WebClient. Dispose (); } Private voidButton2_Click (Objectsender, EventArgs e) {WebClient WebClient=NewWebClient (); WebClient. Proxy=NULL; WebClient. DownloadFile (TextBox2.Text, TextBox3.Text); MessageBox.Show ("Success! "); WebClient. Dispose (); } Private voidButton3_Click (Objectsender, EventArgs e) {WebClient WebClient=NewWebClient (); WebClient. Proxy=NULL; WebClient. DownloadProgressChanged+=webclient_downloadprogresschanged; WebClient. Downloaddatacompleted+=webclient_downloaddatacompleted; WebClient. DownloadFileAsync (NewUri (TextBox2.Text), textbox3.text); WebClient. Dispose (); } voidWebclient_downloaddatacompleted (Objectsender, DownloadDataCompletedEventArgs e) {MessageBox.Show ("Success"); } voidWebclient_downloadprogresschanged (Objectsender, DownloadProgressChangedEventArgs e) {progressBar1.Value=E.progresspercentage; }
Use the WebClient class to download the source code, download the file to save and asynchronous download and report the progress of the download