I m initializing the picturebox with an image like
Image img = Image.FromFile("c:\\image.gif");
picBox.Image = img;
Now, the image image.gif is being updated by another process. I want the picturebox to reflect this updated image file every few seconds(I can put a timer control 4 this).But, what really causes the problem is that the image handle is owned by the picbox and I m unable 2 update it.
What I have done temporarily is alternately write the image in img1.gif and img2.gif and m referencing the images alternatively in the picbox also to avoid conflict.
Thnx in advance for any suggestions or tips.
Happy C#ing

Updating PictureBox Image
GRK
The problem is not with the picture box but with the image. You are opening the image file which takes a lock on the file itself. As long as the image is around the file will be locked. Since you assign the image to the picture box the box will maintain a reference to the image preventing it from being released.
Instead of opening the file and using it directly I'd recommend that you either stream the image in or create a copy of it once it is loaded. Then you can close the original image and thus release the file. You'll do this each time the file changes.
To detect changes to the file without polling I'd recommend that you use FileSystemWatcher which allows you to watch for file changes. Note however that FSW can be somewhat difficult to get a hold on because it generally raises creation and change events when files are modified so you'll have to handle this case. You'll also have to handle the fact that the file will still probably be locked when you try to access it. Of course you're timer has this same problem. Refer to MSDN and the forums for information on working with FSW. It is a popular topic.
Michael Taylor - 2/15/07
http://p3net.mvps.org