what is the meaning of this error "out of memory" when using picturebox1.Image equal to image FromFile(fileName)?
<p>I have a problem now with displaying an image from an exist file ...</p>

<pre><code>try
{   
    bool EndFlag = false;
    string fileLoc = @"../../../../samples/jpeg_" + DateTime.Now.ToString("yyyyMMdd_hhmmss") + ".jpg";
    //Create a file Stream to save the body of the JPEG File content.
    FileStream fs = null;
    fs = new FileStream(fileLoc, FileMode.OpenOrCreate, FileAccess.Write);

    do 
    {
        ReadJpegFileCommand(); 
        CamPort.DiscardOutBuffer();
        CamPort.DiscardInBuffer();

        for (int i = 0; i &lt; 5; i++)
            header[i] = (byte)CamPort.ReadByte();

         if (((int)header[0] == 0x76) &amp;&amp; (header[1] == 0x00) &amp;&amp; (header[2] == 0x32) &amp;&amp; (header[3] == 0x00) &amp;&amp; (header[4] == 0x00))
             {
                for (int i = 0; i &lt; 32; i++)
                        ImageBody[i] = (byte)CamPort.ReadByte();
              /* 
                 * writing the bytes that have been read till now to a file 
              */                    

                    fs.Write(ImageBody, 0, ImageBody.Length);

                    for (int i = 1; i &lt; ImageBody.Length; i++)     // check if reached to the last two bytes(FF D9) of the body to  stop reading the body.
                    {
                        if ((ImageBody[i - 1] == 0xFF) &amp;&amp; (ImageBody[i - 0] == 0xD9))
                        {
                            EndFlag = true;
                            MessageBox.Show("FFD9 has been received");
                            OneSnap.Image =(Bitmap)System.Drawing.Image.FromStream(fs);
                            fs.Close();

                        }
                    }
             }
         else
         {
             MessageBox.Show("Error,Try again"); // The first 5 bytes does not match the header 

         }


         for (int i = 0; i &lt; footer.Length; i++)
         {
             footer[i] = (byte)CamPort.ReadByte();
         }



         // update the starting address 

         M += (UInt16)ImageBody.Length;
         //Progress.PerformStep();


        }while(!EndFlag);


    }



catch (System.Exception ex) { MessageBox.Show(ex.Message); }
</code></pre>

<p>When I have used this statements :</p>

<pre><code>OneSnap.Image =(Bitmap)System.Drawing.Image.FromStream(fs);
                                                            fs.Close();
</code></pre>

<p>I had this error : "Parameter is not valid"</p>

<p>but when I've tried with alternative way and replaced the previous statements by ::</p>

<pre><code> fs.Close();
OneSnap.Image =(Bitmap)System.Drawing.Image.FromFile(fileLoc);
</code></pre>

<p>I showed  the image in the picture box .. but then when I have executed the program more I had this error :: " Out of memory " and couldn't see the image in the picture box (OneSnap) >>> How to solve this ??  </p>

<p>sample :: ( this image has been captured by link Sprite Jpeg Camera )</p>

<p><img src="http://i.stack.imgur.com/ZL3dG.jpg" alt="enter image description here"></p>
