2011-09-14 7 views

答えて

1

私はあなたが意味するものが正確ではないので、これがあなたの問題の解決策ではない場合は、この回答を無視してください。

コードビハインド内のURLから画像をダウンロードし、 画像をローカルに保存してこの画像をブラウザに配信したいとします。

マークアップ

<asp:Image ID="image1" runat="server" /> 

分離コード

protected void Page_Load(object sender, EventArgs e) 
{ 
    if (!IsPostBack) 
    { 
     string imageName = "downloaded-image.png"; 
     string imagePath = Path.Combine(Server.MapPath(@"~\Images"), imageName); 
     string imageUrl = "https://encrypted.google.com/images/logos/ssl_logo.png"; 

     WebClient client = new WebClient(); 
     client.DownloadFile(imageUrl, imagePath); 

     image1.ImageUrl = string.Format(@"~\Images\{0}", imageName); 
    } 
} 

・ホープ、このことができます:この次を使用することができますを行うには

関連する問題