C # download the image to the server code,
C # download the image to the server code
ASPX page code:
<% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "GetPictureByUrl. aspx. cs" Inherits = "HoverTreeMobile. GetPictureByUrl" %> <! DOCTYPE html>
Cs Page code:
Using System; namespace HoverTreeMobile {public partial class GetPictureByUrl: System. web. UI. page {protected void Page_Load (object sender, EventArgs e) {} protected void btnImg_Click (object sender, EventArgs e) {try {System. net. webClient m_hvtWebClient = new System. net. webClient (); string m_keleyiPicture = Server. mapPath ("/hovertreeimages/keleyi.jpg"); // download the m_hvtWebClient.DownloadFile (textBoxImgUrl. text, m_keleyiPicture); hvtImg. imageUrl = "/hovertreeimages/keleyi.jpg"; ltlTips. text = string. empty;} catch (Exception ex) {ltlTips. text = ex. toString ();}}}}
In addition, I would like to share with you the idea of the core method for downloading images.
Using System. net; WebClient myclient = new WebClient (); myclient. downloadFile ("http://www.baidu.com/img/sslm_logo.gif", @ "c: \ baidu.gif"); the address in the DownloadFile method is the URL on the remote server you want to splice.
Well, are you new to me? I hope you will like it.