***********************************************
if (txt_cityname.Text != "")
{
using (StreamWriter str = new StreamWriter("my_weather.txt"))
{
str.WriteLine("City Name: "+lbl_cityName.Text);
str.WriteLine("Country Name: "+lbl_country.Text);
str.WriteLine("Temp Name: "+lbl_Temp.Text);
}
}
****************************************
Image setIcon(string iconID)
{
string url = string.Format("http://openweathermap.org/img/w/{0}.png", iconID); // weather icon resource
var request = WebRequest.Create(url);
using (var response = request.GetResponse())
using (var weatherIcon = response.GetResponseStream())
{
Image weatherImg = Bitmap.FromStream(weatherIcon);
return weatherImg;
}
}
******************************
for WPF Application
BitmapImage seticon()
{
string url = string.Format("http://openweathermap.org/img/w/{0}.png", iconID); // weather icon resource
BitmapImage weatherImg = new BitmapImage();
weatherImg..BeginInit();
weatherImg.UriSource = new Uri(url);
weatherImg.EndInit();
return weatherImg;
}