axWindowsMediaPlayer1获取音频长度
OpenFileDialog openFileDialog1 = new OpenFileDialog { InitialDirectory = "c:\", Filter = "音频文件(*.mp3,*.s48)|*.Mp3;*.s48", FilterIndex = 2, RestoreDirectory = true }; //显示选择文件对话框 var path = ""; if (openFileDialog1.ShowDialog() == DialogResult.OK) { path = openFileDialog1.FileName; //显示文件路径 } if (path.Length == 0) { MessageBox.Show("您还没有选择任何文件!"); return; } IWMPMedia mediaInfo = axWindowsMediaPlayer1.newMedia(path); axWindowsMediaPlayer1.URL = path; MessageBox.Show(mediaInfo.duration.ToString());