title: How to download Sitecore Images
body: <pre><code>var database = Database.GetDatabase(“master”);
  var images = database.SelectItems(“/sitecore/media library/your image folder/descendant::*[@@templatekey=’jpeg’]”);
  
  foreach (var image in images)
  {
  var mediaItem = (MediaItem)image;
  var media = MediaManager.GetMedia(mediaItem);
  var stream = media.GetStream();
  
  using (var targetStream = File.OpenWrite(Path.Combine(“your data path”, image.Name + “.jpeg” )))
  {
  stream.CopyTo(targetStream);
  targetStream.Flush();
  }
  }
  </code></pre>
  
  <p>I'm new to Sitecore, can anyone help me in how to download images from Sitecore to the local folder in our PC and when I searched I found a code but not working. The error is Could not find a part of the path 'E:\Images\RedTorch.jpeg'</p>