This project has moved. For the latest updates, please go here.

naudio AudioFileReader not releasing file?

Jun 16 at 4:44 PM
I should say upfront that I don't expect this is genuinely an naudio problem - but I'm stumped.

My app records the user's voice in discrete phrases, and they can optionally play back their recorded voice, and re-record phrases they are not happy with.

When the app (re)records a phrase, it simply deletes the existing phrase with a call to IO.File.Delete, which normally works fine.

However, if I have played back the phrase first, the call to IO.File.Delete fails with "System.UnauthorizedAccessException: Access to the path <filename> is denied."

Examining with Process Explorer shows, as expected, that only my app has a file handle to the sound file in question.

So, it seems as if the NAudio.Wave.AudioFileReader isn't letting go of the file - even though I explicitly dispose and set the object to nothing when I finish playing the phrase.

Am I missing something? Is there a step I should be taking to explicitly release the file?

Any advice very gratefully received!

Thanks,
Aaron