I use a default image as a user avatar the first time my application is loaded. After that, the user can change their avatar. The problem is that after using a new avatar, the user cannot delete the old avatar. They get the error message: "file access denied". That means my application is still using the old image somewhere, but I don’t know where.
My question is: How do I free the WPF resource after using it? I have looked around with Google, but found nothing.
Please help me!
Thanks.
You usually have to call
Dispose()on class instances after use to free resources. Even better is to use theusingstatement that implicitly callsDispose()like this: