主頁 > 知識庫 > C#實現(xiàn)把圖片下載到服務(wù)器代碼

C#實現(xiàn)把圖片下載到服務(wù)器代碼

熱門標(biāo)簽:上海市三維地圖標(biāo)注 辦公用地圖標(biāo)注網(wǎng)點怎么操作 云南外呼系統(tǒng)代理 南昌自動外呼系統(tǒng)線路 西寧電銷外呼系統(tǒng)公司 安陸市地圖標(biāo)注app 海東防封電銷卡 寧德防封版電銷卡 聊城智能電銷機器人電話

C#實現(xiàn)把圖片下載到服務(wù)器代碼

ASPX頁面代碼:

%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetPictureByUrl.aspx.cs" Inherits="HoverTreeMobile.GetPictureByUrl" %>
!DOCTYPE html>
html xmlns="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>根據(jù)網(wǎng)址把圖片下載到服務(wù)器/title>
/head>
body>
 form id="form1" runat="server">
 div>
 圖片網(wǎng)址:br />asp:TextBox runat="server" ID="textBoxImgUrl" Width="500" Text="/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");

    //根據(jù)網(wǎng)址下載文件
    m_hvtWebClient.DownloadFile(textBoxImgUrl.Text, m_keleyiPicture);

    hvtImg.ImageUrl = "/hovertreeimages/keleyi.jpg";
    ltlTips.Text = string.Empty;
   }
   catch(Exception ex)
   {
    ltlTips.Text = ex.ToString();
   }

  }
 }
}

另外給大家分享一下下載圖片的核心方法的思路

using System.Net;
      WebClient myclient = new WebClient();
      myclient.DownloadFile("http://www.baidu.com/img/sslm_logo.gif",@"c:\baidu.gif"); 
DownloadFile方法里的address就是你要拼成的遠程服務(wù)器上的URL.

好了,小伙伴們是否有了新的認識了呢,希望大家能夠喜歡。

您可能感興趣的文章:
  • Asp.net(C#)讀取數(shù)據(jù)庫并生成JS文件制作首頁圖片切換效果(附demo源碼下載)
  • C#實現(xiàn)上傳下載圖片
  • C#.NET中如何批量插入大量數(shù)據(jù)到數(shù)據(jù)庫中
  • c#批量上傳圖片到服務(wù)器示例分享
  • C#實現(xiàn)SQL批量插入數(shù)據(jù)到表的方法
  • C#/.Net 中快速批量給SQLite數(shù)據(jù)庫插入測試數(shù)據(jù)
  • C#實現(xiàn)的文件批量重命名功能示例
  • C#實現(xiàn)批量下載圖片到本地示例代碼

標(biāo)簽:崇左 汕尾 南寧 衢州 贛州 青海 洛陽

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《C#實現(xiàn)把圖片下載到服務(wù)器代碼》,本文關(guān)鍵詞  實現(xiàn),把,圖片下載,到,服務(wù)器,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《C#實現(xiàn)把圖片下載到服務(wù)器代碼》相關(guān)的同類信息!
  • 本頁收集關(guān)于C#實現(xiàn)把圖片下載到服務(wù)器代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 企业400电话

    智能AI客服机器人
    15000

    在线订购

    合计11份范本:公司章程+合伙协议+出资协议+合作协议+股权转让协议+增资扩股协议+股权激励+股东会决议+董事会决议

    推薦文章