I am trying to close a media player after I close a form. Here is my code
WMPPlaylistArrayprivate void FrmGameOption_FormClosing(object sender, FormClosingEventArgs e)
{
WMPLib.I plCollection = wplayer.playlistCollection.getByName("myplaylist");
if (plCollection.count > 0)
{
WMPLib.IWMPPlaylist pl = plCollection.Item(0);
wplayer.playlistCollection.remove(pl);
}
wplayer.controls.stop();
File.Delete(@"C:\Users\jacob\Music\Playlists\myplaylist.wpl");
}
It stopped at the line "WMPLib.IWMPPlaylist pl = plCollection.Item(0);" and the error is 'the system cannot find the file specified'. What I cannot understand is that it is in a condition that 'plCollection.count>0'. If more than one items exists, how comes it cannot find the file?
I am trying to remove a playlist form playlist array. I set the condition to ensure there is playlist. But error popped up and said it could not find the file.