C# 远程保存图片 图片远程保存

 

html 代码

    请输入要保存的文件名
    
< asp:TextBox  ID ="TextBox2"  runat ="server" > D:/dd1.jpg asp:TextBox >
    
< asp:Button  ID ="Button1"  runat ="server"  OnClick ="Button1_Click"  Text ="Button"   />   < br  />
    
  < br  />
    请输入以知图像路径 
  < asp:TextBox  ID ="imgurl"  runat ="server" > http://image2.sina.com.cn/sms/images/sinapic/27126115-0.jpg asp:TextBox >   < br  />
    
< asp:TextBox  ID ="TextBox1"  runat ="server"  Height ="373px"  Width ="527px" > asp:TextBox >   < div
        
id ="DIV1"  runat ="server"  style ="width: 100px; height: 100px" >
    
div >

 

 

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
public partial class createtab : System.Web.UI.Page
{
    Tong.TongUse TextData = new Tong.TongUse();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        TextBox1.Text = Crtimg();
    }


    ///


    /// 以下代码实现远程保存图片
    ///

    ///
    string Crtimg()
    {
        System.Net.WebClient WC = new WebClient();
        WC.DownloadFile(imgurl.Text, TextBox2.Text.Trim());
        WC.Dispose();
        return TextBox2.Text.Trim();

    }
}
 

你可能感兴趣的:(C# 远程保存图片 图片远程保存)