File is locked when loading an image RRS feed

  • Question

  • When loading an image from a file in .NET, e.g. with System.Drawing.Image.FromFile or FromStream, the file remains locked as long as the image object exists. This is really annoying because I'm writing an application that displays images that the user is likely to edit sometimes. Restarting the entire application is not an option here. If only the file wasn't locked, I could manage the rest of updating it at due time, but that's impossible in the first place right now. How can I unlock the file while the image is used or not lock it at all?

    I have already found this related KB article: http://support.microsoft.com/kb/311754/DE/ - but it doesn't provide a solution either.

    Thursday, April 1, 2010 10:05 PM