Benny Sutton is 4 hire - just click here

Validate File is Audio

Test a string could be an audio file supported by the HTML5 audio player i.e. wav/mp3/ogg see regexr.com/5v0u8

           
        public static bool IsAudio(this string FileName)
        {
            return Regex.Match(FileName, @".*(\.[Ww][Aa][Vv]|\.[Mm][Pp][3]|\.[Oo][Gg][Gg])\b").Success;
        }
 
    

Returns true/false - call like this...

         
            if (!httpPostedFile.FileName.GetFileName().IsAudio()) throw new Exception("File does not have an audio file extension");