---
title: "Saving Image files in server after response"  
description: "Saving Image files in server after response"  
author: "Anonymous User"  
published: 2014-12-18  
updated: 2014-12-19  
canonical: https://www.mindstick.com/forum/12794/saving-image-files-in-server-after-response  
category: "asp.net"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Saving Image files in server after response

My [asp.net](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder) [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) [saving](https://www.mindstick.com/blog/11865/guide-to-saving-15-for-retirement) a long list of image files and then have to view [one of them](https://answers.mindstick.com/qa/47593/what-are-the-prevalent-water-proofing-systems-write-a-short-notes-on-any-one-of-them). The [client](https://www.mindstick.com/articles/23198/3-steps-to-ensure-that-your-client-portal-is-impeccable) can browse the [images](https://www.mindstick.com/interview/1067/what-is-the-php-predefined-variable-that-tells-the-what-type-of-images-that-php-support), But its take a long time. I have a [dictionary](https://www.mindstick.com/articles/1500/hashtable-and-dictionary-in-c-sharp) with key - [file path](https://www.mindstick.com/forum/161592/how-do-you-validate-whether-a-given-path-is-a-valid-file-path-or-not) and value -Image:

```
Dictionary<string, System.Drawing.Image> imageList = new Dictionary<string,System.Drawing.Image>(); //filling imageList foreach (KeyValuePair<imagePath, System.Drawing.Image> item in imageList){    item.Value.Save(item.Key, System.Drawing.Imaging.ImageFormat.Jpeg);}
```

I [am looking](https://answers.mindstick.com/qa/115463/i-am-looking-for-to-joining-the-mindstick-internship-program-how-to-apply) for some way to save just one image file, make [response](https://www.mindstick.com/forum/12719/how-to-make-response-write-display-special-character-like-lt-gt), and continue saving the other image files, there is any way to do it? maybe with Thread? Thanks!

## Replies

### Reply by Mark Devid

I put the images saving in thread block and it works perfectly and fast:

```
Dictionary<string, System.Drawing.Image> imageList =new Dictionary<string,System.Drawing.Image>(); //filling imageList Thread thread = new Thread(() =>{   foreach(KeyValuePair<string, System.Drawing.Image> image in imageList)    {       image.Value.Save(item.Key,System.Drawing.Imaging.ImageFormat.Jpeg);    }});thread.Start();
```

### Reply by Anonymous User

Disk IO may be very slow, nevertheless you can try this

```
foreach (KeyValuePair<string, System.Drawing.Image> item in imageList)    Task.Factory.StartNew(() =>    {        lock (item.Value)            item.Value.Save(item.Key, System.Drawing.Imaging.ImageFormat.Jpeg);    });
```


---

Original Source: https://www.mindstick.com/forum/12794/saving-image-files-in-server-after-response

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
