How can I determine the length (i.e. duration) of a .wav file in C#?

Download NAudio.dll
from the link
https://www.dll-files.com/naudio.dll.html

and then use this function

public static TimeSpan GetWavFileDuration(string fileName)       
{     
    WaveFileReader wf = new WaveFileReader(fileName);
    return wf.TotalTime; 
}

you will get the Duration

Leave a Comment