title: How can I load an Image from a file without keeping the file locked?
body: <p>I wish to display an image in a PictureBox, loading the image from a file. The file gets overwritten periodically though, so I can't keep the file locked. I started by doing this:</p>
  
  <p><code>pictureBox.Image = Image.FromFile( fileName );</code></p>
  
  <p>However, this keeps the file locked. Then I tried to read through a stream:</p>
  
  <pre><code>using (System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read))
  {
      pictureBox.Image = Image.FromStream(fs);
  } 
  </code></pre>
  
  <p>This doesn't lock the file, but <em>does</em> cause an exception to be thrown later on; MSDN indicates that the stream must be kept open for the lifetime of the image. (The exception includes a message that "A closed file may not be read" or similar.)</p>
  
  <p>How can I load an image from a file, then have no further references to the file?</p>