Question: I am currently coding a C# application that displays a image using PictureBox on a form.

Now, I want to update this image consistently (e.g. every 2 seconds). But I am not able to do this.

Because the new image is also of the same file directory/name and it will be replacing the original image which is loaded. So when I want to replace the image it is showing, "file is being used by another program...etc)."

Basically, I want to use PictureBox to load an image and this image will be consistently updated as the loaded image is being changed at it's directory.

Is this possible? Is there any other way to do this in C#?

Thanks In Advance,
Perumal

Answer: 
It sounds as if a stream isn't closed. Try to call `stream.close();` after you have loaded your image. If you are loading your image like this `Image i = new Image(File.Open("blub.png"));` Then you will have to rewrite it a bit like this;

```
FileStream fs = File.Open("blub.png");
Image img = new Image(fs);
fs.Close();
fs.Dispose();

```
Just use a timer (called `timeImageChange` in the example below) and rename the files two different files names. Then you could have something like 

```
bool imageALoaded = true;
timerImageChange.Interval = 2000;
timerImageChange.Enabled = true;

private void timerImageChange_Tick(object sender, EventArgs e)
{
    if (imageALoaded)
    {
        this.pictureBox1.Image = imageB;
        imageALoaded = false;
    }
    else
    {
        this.pictureBox1.Image = imageA;
        imageALoaded = true;
    }
}

```

This should do what you want.

I hope this helps.