public static int GetAudioDuration(String audioFileName)
        {
            MepgInfo mepgInfo = new MepgInfo();

            GetMepgInfo(audioFileName, ref mepgInfo);
            return(mepgInfo.Duration);
        }
        public static Boolean GetMepgInfo(String audioFileName, ref MepgInfo mepgInfo)
        {
            if (File.Exists(audioFileName))
            {
                FileStream mepgFileStream = null;

                try
                {
                    mepgFileStream = File.Open(audioFileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                }
                catch
                {
                    return(false);
                }

                try
                {
                    mepgInfo.FileSize = mepgFileStream.Length;
                    Byte[] headerBuffer = new Byte[32];
                    int    byteRead     = mepgFileStream.Read(headerBuffer, 0, 4);
                    if (byteRead == 4)
                    {
                        mepgInfo.FileIsMPEG = IsMepg(headerBuffer[0], headerBuffer[1], headerBuffer[2], headerBuffer[3]);
                        if (!mepgInfo.FileIsMPEG)
                        {
                            return(false);
                        }
                        mepgInfo.Layer        = GetLayer(headerBuffer[1]);
                        mepgInfo.BitRate      = GetBitRate(mepgInfo.Layer, headerBuffer[2]);
                        mepgInfo.SamplingFreq = GetSampleFreq(headerBuffer[1], headerBuffer[2]);
                        mepgInfo.FrameSize    = GetFrameSize(mepgInfo.Layer, mepgInfo.BitRate, mepgInfo.SamplingFreq);
                        mepgInfo.Duration     = GetDuration(mepgInfo.FileSize, mepgInfo.FrameSize, mepgInfo.SamplingFreq);
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                finally
                {
                    mepgFileStream.Close();
                }
            }
            else
            {
                return(false);
            }
        }