The release number of this article has been CHS311754
For Microsoft Visual Basic .NET versions of this article, see
309482.
Symptoms When using a picture file
When the PictureBox control, the Microsoft Visual Studio .NET integration development environment (IDE) maintains the lock state of the file. This problem occurs in the following cases:
Picturebox control
Image property is manually set to file, or use it when running
The fromfile method has made this setting.
To resolve this issue, please use this below
FILESTREAM object:
// Make Sure That You Have Added The System.io Namespace.
Using system.io;
// Specify a Valid Picture File Path ON your computer.
FileStream Fs;
Fs = new filestream ("c: // winnt // web // Wallpaper // fly away.jpg", filemode.open, fileaccess.read;
Picturebox1.image = system.drawing.image.fromstream (fs);
fs.close ();
This phenomenon is designed to make.
More information
If design is set when designing
Picturebox control
Image properties, Visual Studio .NET IDE will lock the image file. Even reset
Image attribute or delete
PictureBox control, the image file remains locked. Unique way to cancel the image file lock is to close the Visual Studio .NET IDE.
Recount behavior steps
In Visual Studio .NET, create a new Visual C # Windows application project. FORM1 will be created by default. Add a PictureBox control to FORM1, set the Image property to a picture file. In the Windows Explorer, try renaming a picture file as a PictureBox control image property. You will receive a shared conflict error message. In the Properties window, right-click the image property and click Reset. Try rename the image file. You will receive a shared conflict error message. Remove the PictureBox control from Form1, then try rename the image file from the Windows Explorer. You will receive a shared conflict error message again.
If you are running
Image.fromfile method loads the picture to
In the PictureBox control, the image file is locked when the application is started. This image file remains a locked state when the application is running. Even when running
Image property is set to
Nothing, the image file will still be locked.
Recount behavior steps
In Visual Studio .NET, create a new Visual C # Windows application project. FORM1 will be created by default. Add a PictureBox control and a Button control to FORM1. Paste the following code into the Click event of the Button control: // Specify a Valid Picture File Path ON Your Computer.
Picturebox1.image = image.fromfile ("c: // winnt // Web /// Wallpaper // Fly Away.jpg"); press F5 to run the app, then click the Button control to load the image to the PictureBox control in. When the application is run, try to rename the image file using the Windows Explorer. You will receive a shared conflict error message. The information in this article applies to:
Microsoft Visual C # .NET (2002)
Recent Updated: 2002-1-17 (1.0) Keyword KBPRB KB311754