Article ID: 309482 - Last Review: February 12, 2007 - Revision: 2.1 Image file is locked when you set the PictureBox Image property to a fileThis article was previously published under Q309482 For a Microsoft Visual C# .NET version of this article, see 311754
(http://support.microsoft.com/kb/311754/EN-US/
)
.
On This PageSYMPTOMS
When you load a PictureBox control with a picture file, the Microsoft Visual Studio .NET or Microsoft Visual Studio 2005 Integrated Development Environment (IDE) maintains a lock on the file. This occurs when you set the Image property of a PictureBox control to a file manually at design time, or when you use the FromFile method at run time.
RESOLUTION
To work around this problem, use the FileStream object as follows:
STATUSThis behavior is by design. MORE INFORMATIONDesign TimeWhen you set the Image property of a PictureBox control at design time, the Visual Studio .NET or Visual Studio 2005 IDE locks the picture file. The picture file remains locked even if you reset the Image property or delete the PictureBox control. The only way to unlock the picture file is to close the Visual Studio .NET or Visual Studio 2005 IDE.Steps to Reproduce Behavior
Run TimeIf you use the Image.FromFile method to load a picture in a PictureBox control, the picture file is locked when you start the application. The picture file remains locked while the application runs. The picture file is locked even if you set the Image property to Nothing at run time.Steps to Reproduce Behavior
| Article Translations
|

Back to the top
