1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
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());
|