How do you save the image? Have you made sure that you dispose all Image and Stream
objects that are used for saving the image? Since both Image
and Stream
(and StreamWriter
) implement IDisposable
you should make sure to call Dispose
(or set up using blocks when creating the objects) so that the file is properly closed when the image has been saved.
Update: One thing that you could try is to save the image data yourself, in order to gain more control over exactly how it is done:
private static void SaveFile(Stream input, string fileName)
{
using (Stream output = File.OpenWrite(fileName))
{
byte[] buffer = new byte[8192];
int bytesRead;
do
{
bytesRead = input.Read(buffer, 0, buffer.Length);
output.Write(buffer, 0, bytesRead);
} while (bytesRead == buffer.Length);
}
}
// Pass the uploaded file data to the above method like this:
SaveFile(fupAddImage.FileContent, Path.Combine(Server.MapPath("Temp"), tempFilename))