Using the code:
using (var reader = new WaveFileReader(audioFileLocation))
{
// Do something....
}
If given a wav file that throws the exception:
Not a WAVE file - no RIFF header
Exception Details: System.FormatException: Not a WAVE file - no RIFF header
It locks the file audioFileLocation
which prevents it from being deleted.
Is there any way to check for the existence of a valid RIFF header before using the reader?
WaveFileReader
in that it doesn't close the file. Where did you get that class? - Lasse V. KarlsenNAudio.Wave.WaveFileReader
class - Tom GullenWaveFileReader
class has a bug here. According to the source code on codeplex, here: naudio.codeplex.com/SourceControl/latest#NAudio/Wave/…, it checks if the file is a valid RIFF file before setting theownInput
parameter, and thus doesn't close the stream if given an invalid file. - Lasse V. Karlsen