Initialize SharePodLib and get a list of all tracks on an iPod.
* GetConnectediPod() searches through all drives on the PC to find an iPod. For performance reasons, it should only be called once, and the IPod object it returns should be used for all subsequent iPod usage.
IPod _iPod = null;
try 
{ 
    _iPod = SharePodLib.IPod.GetConnectediPod();
}
catch (BaseSharePodException ex) 
{ 
    MessageBox.Show(ex.Message);
    return; 
} 
foreach (Track track in _iPod.Tracks) 
{ 
    Debug.WriteLine(String.Format("{0} - {1} - {2}", track.Title, track.Artist, track.Album); 
}
        


Add a new track to the iPod.
When setting the NewTrack properties, only FilePath and IsVideo are required.
NewTrack newTrack = new NewTrack();
newTrack.Title = "my new track";
newTrack.Album = "my album";
newTrack.FilePath = "c:\test.mp3";
newTrack.IsVideo = false;
newTrack.ArtworkFile = "c:\test-artwork.jpg";
try 
{ 
    Track addedTrack = _iPod.Tracks.Add(newTrack);
    addedTrack.Rating = new IPodRating(4); //give the new track a 4-star rating;
    _iPod.SaveChanges();  // At this point, the actual file is on the iPod, so we should save database changes.
}
catch (BaseSharePodException ex) 
{ 
    MessageBox.Show(ex.Message);
    return; 
} 
        


Delete all tracks in the 'Abbey Road' album.
try 
{ 
    for (int count = _iPod.Tracks.Count - 1; count >= 0; count--)
    {
        Track currentTrack = _iPod.Tracks[count];
        if (currentTrack.Album == "Abbey Road")
        {
            _iPod.Tracks.Remove(currentTrack);
        }
    }
    // At this point, the actual files have been deleted, so we should save database changes.
    _iPod.SaveChanges();
}
catch (Exception ex) 
{ 
    MessageBox.Show(ex.Message);
} 
        


Create a new playlist (called "New Playlist") and add a track to it.
Modify that track (in this case the comment field).
Use the the IPodExporter class to copy a track to the users c:\ drive:
Track firstTrack = _iPod.Tracks[0];
Playlist newPlaylist = null;
try { 
    newPlaylist = iPod.Playlists.Add("New Playlist"); 
    newPlaylist.AddTrack(firstTrack);
} 
catch (BaseSharePodException ex) 
{ 
    MessageBox.Show(ex.Message); 
    return;
} 
firstTrack.Comment = "Modified by SharePodLib"; 
IPodFileExporter exporter = new IPodFileExporter(_iPod, "c:\\", "[Artist] - [Album] - [Title]"); 
List<Track> tracksToCopy = new List<Track>();
tracksToCopy.Add(firstTrack);
exporter.SetTracksToCopy(tracksToCopy);
// we could also say exporter.SetPlaylistsToCopy(...);
exporter.PerformCopy();

// before we close the program, we need to save any changes we've made.
_iPod.SaveChanges(); 


Get notified when an iPod is connected & disconnected from the computer.
//the event handlers
SharePodLib.Device.iPodConnected += new iPodConnectedHandler(Device_iPodConnected);
SharePodLib.Device.iPodDisconnected += new iPodDisconnectedHandler(Device_iPodDisconnected);

//tell SharePodLib to listen for new iPods
SharePodLib.Device.ListenForDeviceChanges(myWindow.Handle);
 
public void Device_iPodConnected(IPod iPod) 
{ 
    //do stuff with new iPod! 
}