-2

この方法で画像をダウンロードしました。

 public Image getImageFromURL(String sURL)
    {
        using (WebClient wc = new WebClient())
        {
            var data = wc.DownloadData(sURL);
            var image = Image.FromStream(new MemoryStream(data));
            return image;
        }

    }

私のカミソリビューでは Bitmap object が返されますが、ダウンロードした画像を表示したい場合は機能しません

前もって感謝します

4

1 に答える 1

0

If you get Image in response from your getImageFromURL(String sURL) method. you need to store image at any location in your application, then you can render it on view. you can use this code.

var image = Image.FromStream(new MemoryStream(data));

string path=Path.Combine(Server.MapPath("~/images"), imagename); image.Save(path);

this will save image at your images folder, and then you can render your image from this images folder location on view.

<img src="~/images/imagename" alt="" />

于 2013-06-01T08:40:31.087 に答える