Exemple #1
0
        private void DownloadWeatherDetailsOffline(string city)
        {
            WeatherDetails _weather = null;
            string url = GetUrl(ref _weather);
            string weatherDetails = _weather.DownloadWeatherDetails(url);

            string dirPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory.Replace("bin\\Debug\\", "Offline Datas\\"), SelectedWeatherSource);
            if (!Directory.Exists(dirPath))
                Directory.CreateDirectory(dirPath);

            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory.Replace("bin\\Debug\\", "Offline Datas\\"), string.Format("{0}\\{1}.txt", SelectedWeatherSource, city));
            if (File.Exists(path))
                File.Delete(path);
            using (StreamWriter writer = new StreamWriter(path))
            {
                writer.WriteLine(weatherDetails);
                writer.Close();
            }
            MessageBox.Show("Downloaded Successfully !!!");
        }