星空网 > 软件开发 > ASP.net

根据网址把图片下载到服务器C#代码

根据网址把图片下载到服务器C#代码

 

ASPX页面代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetPictureByUrl.aspx.cs" Inherits="HoverTreeMobile.GetPictureByUrl" %><!DOCTYPE html><html ="http://www.w3.org/1999/xhtml"><head runat="server"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>  <meta name="viewport" content="width=device-width, initial-scale=1" />  <title>根据网址把图片下载到服务器 - 何问起</title></head><body>  <form id="form1" runat="server">  <div>  图片网址:<br /><asp:TextBox runat="server" ID="textBoxImgUrl" Width="500" Text="http://hovertree.com/hvtimg/201508/cnvkv745.jpg" />   <br />  <asp:Button runat="server" ID="btnImg" Text="下载" OnClick="btnImg_Click" />    <br /><asp:Image runat="server" ID="hvtImg" />    <br />    <asp:Literal runat="server" ID="ltlTips" />  </div>  </form></body></html>

 

cs页面代码:

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");        //根据网址下载文件        m_hvtWebClient.DownloadFile(textBoxImgUrl.Text, m_keleyiPicture);        hvtImg.ImageUrl = "/hovertreeimages/keleyi.jpg";        ltlTips.Text = string.Empty;      }      catch(Exception ex)      {        ltlTips.Text = ex.ToString();      }    }  }}

HoverTree 开源项目

新增根据网址把图片下载到服务器功能

请看 HoverTreeMobile 项目

http://hovertree.com

何问起

源代码下载 http://files.cnblogs.com/files/jihua/hovertreeCode.rar

 根据网址把图片下载到服务器C#代码

http://www.cnblogs.com/jihua/p/webfront.html




原标题:根据网址把图片下载到服务器C#代码

关键词:C#

C#
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流