1private Image GetImageFromURL(string strUrl)
2{
3 //建立一個 Web Request
4 HttpWebRequest MyHttpWebRequest = (HttpWebRequest)WebRequest.Create(strUrl);
5 //由 Web Request 取得 Web Response
6 HttpWebResponse MyHttpWebResponse = (HttpWebResponse)MyHttpWebRequest.GetResponse();
7 //由 Web Response 取得 Stream
8 Stream MyStream = MyHttpWebResponse.GetResponseStream();
9 //由 Stream 取得 Image
10 Image MyImage = Image.FromStream(MyStream);
11
12 //該關的關一關, 該放的放一放
13 MyStream.Close();
14 MyStream.Dispose();
15 MyHttpWebResponse.Close();
16 MyHttpWebResponse = null;
17 MyHttpWebRequest = null;
18
19 //回傳 Image
20 return MyImage;
21}
2{
3 //建立一個 Web Request
4 HttpWebRequest MyHttpWebRequest = (HttpWebRequest)WebRequest.Create(strUrl);
5 //由 Web Request 取得 Web Response
6 HttpWebResponse MyHttpWebResponse = (HttpWebResponse)MyHttpWebRequest.GetResponse();
7 //由 Web Response 取得 Stream
8 Stream MyStream = MyHttpWebResponse.GetResponseStream();
9 //由 Stream 取得 Image
10 Image MyImage = Image.FromStream(MyStream);
11
12 //該關的關一關, 該放的放一放
13 MyStream.Close();
14 MyStream.Dispose();
15 MyHttpWebResponse.Close();
16 MyHttpWebResponse = null;
17 MyHttpWebRequest = null;
18
19 //回傳 Image
20 return MyImage;
21}