Ok. i have a fairly large media library at home. not just music, but recorded TV shows from my Media Center and podcasts. when it comes to the TV shows, there is a problem with some being deleted and still showing up in Media Center, but i cant test with that, just yet. maybe later. Anyway, as i said, i have a lot of podcasts downloaded into media player and when i clean them off the hard drive, they still show up in WMP and MCE. So, check out this code:

       private void Form1_Load(object sender, EventArgs e)<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">

        {</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"> </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">            WMPLib.WindowsMediaPlayer wmp = new WMPLib.WindowsMediaPlayer();</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">            WMPLib.IWMPPlaylist playList = wmp.mediaCollection.getByAttribute(“MediaType”, “Audio”);</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">            WMPLib.IWMPMediaCollection coll;</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">            coll = wmp.mediaCollection;</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">            System.IO.FileInfo f;</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">            for (int i = 0; i < playList.count; i++)</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">            {</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">                if (playList.get_Item(i).duration > 0)</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">                {</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">                    f = new System.IO.FileInfo(playList.get_Item(i).sourceURL);</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">                    if (!f.Exists)</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">                    {</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">                        MessageBox.Show(playList.get_Item(i).sourceURL);</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">                        MessageBox.Show(playList.get_Item(i).name);</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">                        coll.remove(playList.get_Item(i), true);                </p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">                    }</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">                }</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">            }</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">            coll = null;</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">            wmp = null;</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none">            playList = null;</p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt">        }</p>

Basicly, the code gets all audio from Windows Media Player, checks to see if it exists on the hard drive, and if not, deletes it from the media library. as you can see on line 5 or 6 (depends on how you count it) the we are asking just for Audio. this can be changed to getAll to get everything including playlists, but at the moment, i just want audio. the MessageBoxs are only there for show. There is some more tips on using the Media Player COM object for managing your music library here on TechNet. there are some really interesting things in there, like the creating a Random Playlist tip or the Copying Media collection information to an Excel Spreadsheet tip. [update] For some more advanced topics on this subject, check out the Windows Media Player 10 SDK over at the MSDN. lots of pages with lots of information. very cool stuff.