Esempio n. 1
0
        /// <summary>
        /// Check if the My Devices folder exists, if not create it.
        /// </summary>
        private void CreateMyDevicesFolder()
        {
            try
            {
                foreach (IITPlaylist p in itunes.LibrarySource.Playlists)
                {
                    if (p.Name == "My Devices" && p.Kind == ITPlaylistKind.ITPlaylistKindUser)
                    {
                        folderMyDevices = (IITUserPlaylist)p;
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                l.Error(ex);
            }

            try
            {
                object src = itunes.LibrarySource;
                folderMyDevices = (IITUserPlaylist)itunes.CreateFolderInSource("My Devices", ref src);
            }
            catch (COMException ex)
            {
                l.Error(ex);

                MessageBox.Show(this, "Unable to create 'My Devices' folder. This may "
                                + "be due to iTunes being busy with an other operation. If this error "
                                + "continues to occur, please turn the option off in the Preferences dialog.\n\n(" + ex.Message + ")",
                                "Failed to create My Devices folder", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }