濮阳杆衣贸易有限公司

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

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

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

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

ASPX頁(yè)面代碼:

%@ 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頁(yè)面代碼:

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就是你要拼成的遠(yuǎn)程服務(wù)器上的URL.

好了,小伙伴們是否有了新的認(rèn)識(shí)了呢,希望大家能夠喜歡。

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

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

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《C#實(shí)現(xiàn)把圖片下載到服務(wù)器代碼》,本文關(guān)鍵詞  實(shí)現(xiàn),把,圖片下載,到,服務(wù)器,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《C#實(shí)現(xiàn)把圖片下載到服務(wù)器代碼》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于C#實(shí)現(xiàn)把圖片下載到服務(wù)器代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    吉林省| 清新县| 梅州市| 宣恩县| 布拖县| 周至县| 青州市| 新竹市| 贞丰县| 柯坪县| 白城市| 泸西县| 左贡县| 张家口市| 沈丘县| 理塘县| 若尔盖县| 长兴县| 西乡县| 图们市| 雅江县| 山阳县| 化隆| 仙桃市| 南宁市| 平定县| 兴海县| 井冈山市| 疏勒县| 洪泽县| 肇庆市| 合江县| 封开县| 南昌市| 滦南县| 伊通| 大厂| 乐山市| 平邑县| 克什克腾旗| 平塘县|