private void GetInitImage() { try { var getImmageRequest = WebRequest.Create(popular); var response = getImmageRequest.GetResponse(); var stream = response.GetResponseStream(); if (stream != null) { using (var reader = new StreamReader(stream)) { var s = reader.ReadToEnd(); var uri = GetImageUri(s); if (!string.IsNullOrWhiteSpace(uri)) { //var client = new WebClient(); //client.DownloadFile(uri, Environment.CurrentDirectory + "\\wallpaper.jpg"); pictureBox1.Load(uri); //pictureBox1.Image.Save(Environment.CurrentDirectory + "\\wallpaper.jpg", ImageFormat.Png); Wallpaper.Set(new Uri(uri), Wallpaper.Style.Filled, Wallpaper.FileType.Jpg); } } } } catch (Exception e) { Console.WriteLine(e); } }
private void SetImage(string uri) { try { //var client = new WebClient(); //client.DownloadFile(uri, Environment.CurrentDirectory + "\\wallpaper.jpg"); pictureBox1.Load(uri); Wallpaper.Set(new Uri(uri), Wallpaper.Style.Filled, Wallpaper.FileType.Jpg); } catch (Exception e) { Console.WriteLine(e); } }