なぜ私はtryブロック内のURLから取得した画像を返すことができませんか? 。 悪い英語:(申し訳ありませんC#try-catchブロックからの返信
これは私が取得エラーです:
Returnステートメントは、私がこだわっているので、すべてのヘルプは、いただければ幸い
public static Image GetExternalImg(string name, string size)
{
try
{
// Get the image from the web.
WebRequest req = WebRequest.Create(String.Format("http://www.picturesite.com/picture.png", name, size));
// Read the image that we get in a stream.
Stream stream = req.GetResponse().GetResponseStream();
// Save the image from the stream that we are rreading.
Image img = Image.FromStream(stream);
// Save the image to local storage.
img.Save(Environment.CurrentDirectory + "\\images\\" + name + ".png");
return img;
}
catch (Exception)
{
}
}
が欠落しています今すぐ:
例外がキャッチされたら表示します。私は可能ですか? –
もちろん、イメージをaとして埋め込みますn埋め込みリソースと見て:http://stackoverflow.com/questions/1192054/load-image-from-resources-in-c-sharp –
ありがとう、私は試してみるつもり:) –