tags:

views:

28

answers:

1

Hi all

I used a image as user avatar at the first time my application was loaded. After that, user can change their avatar. But the problem is that after using a new avatar user cannot delete old avatar. The error message show that : "file access denied". That means my application is still using old image somewhere but I don't know.

My question is how to free WPF resource after using it. I have took around google but get nothing

please help me!

thanks

A: 

You usually have to call Dispose() on class instances after use to free resources. Even better is to use the using statement that implicitly calls Dispose() like this:

using (FileStream fsSource = new FileStream(pathSource, FileMode.Open, FileAccess.Read))
{
    // Load file content
}
Mart