public void Refresh()
        {
            if (lastRefresh == DateTime.MinValue)
            {
                // we never successfully loaded the CFL, so let's do it again
                Load();
                return;
            }

            IFeedsManager fs = new FeedsManager();

            try
            {
                IFeedFolder folder = (IFeedFolder)fs.GetFolder(Properties.Settings.Default.ImagePathOverride);
                foreach (IFeed feed in CommonFeedListUtils.LastWriteSince(folder, lastRefresh))
                {
                    RssFeed rssFeed = null;
                    try
                    {
                        // This feed was updated or is new, let's get it.
                        rssFeed = RssFeed.FromApi(feed);
                    }
                    catch (System.Runtime.InteropServices.COMException ex)
                    {
                        System.Diagnostics.Debug.Print("Failed to get RSS feed '{0}' from API; skipping feed. Error: {1} ", feed.Name, ex.ToString());
                        continue;  // Skip this feed.
                    }

                    // If the feed has no items with picture enclosures then skip it.
                    if (rssFeed == null || rssFeed.Items.Count == 0)
                    {
                        System.Diagnostics.Debug.Print("Feed '{0}' does not have any picture enclosures; skipping feed.", feed.Name);
                        continue;
                    }

                    // Before we add it let's see if we have an old version of the feed.
                    int index = rssFeeds.FindIndex(delegate(RssFeed f) { return (f.Path == rssFeed.Path); });
                    if (index == -1)
                    {
                        // This must be a new feed, let's append it to the list.
                        rssFeeds.Add(rssFeed);
                    }
                    else
                    {
                        // We have an existing feed with the same path. Let's insert it
                        // where the previous feed is at.
                        rssFeeds.Insert(index, rssFeed);

                        // Remove previous feed.
                        rssFeeds.RemoveAt(index + 1);

                        // Assure that current indexes are not out of bounds.
                        ValidateIndexes();
                    }
                }
            }
            finally
            {
                GC.Collect(); // Release all COM objects and their file handles.
                lastRefresh = DateTime.Now;
            }
        }
 // Verify that folder exists
 private bool ExistsFolder(string name)
 {
     // This code is encapsulated here because it will cause an exception
     // _as the stack is constructed_ if the Interop.Feeds.dll is not installed properly.
     IFeedsManager fm = new FeedsManager();
     return fm.ExistsFolder(name);
 }
        public void Load()
        {
            DateTime loadstart = DateTime.Now;
            List<RssFeed> newRssFeeds = new List<RssFeed>();

            try
            {
                IFeedsManager fs = new FeedsManager();
                IFeedFolder folder = (IFeedFolder)fs.GetFolder(Properties.Settings.Default.ImagePathOverride);
                foreach (IFeed feed in CommonFeedListUtils.CommonFeedList(folder))
                {
                    System.Diagnostics.Debug.Print("Found feed {0} with {1} items.",
                        feed.Name, ((IFeedsEnum)feed.Items).Count);
                    try
                    {
                        RssFeed rssFeed = RssFeed.FromApi(feed);

                        // Only add this feed if it contains items
                        if (rssFeed != null)
                        {
                            System.Diagnostics.Debug.Print("Feed has {0} items with enclosures.", rssFeed.Items.Count);
                            if (rssFeed.Items.Count > 0)
                                newRssFeeds.Add(rssFeed);
                        }
                        else
                            System.Diagnostics.Debug.Print("Feed is null.");
                    }
                    catch (System.Runtime.InteropServices.COMException ex)
                    {
                        System.Diagnostics.Debug.Print("Failed to get RSS feed '{0}' from API; skipping feed. Error: {1} ", feed.Name, ex.ToString());
                        // Ignore exception, meaning ignore this feed and continue with next feed.
                    }
                }
            }
            finally
            {
                // Collect garbage so that all the COM objects are released which
                // closes the backing structured storage files.
                GC.Collect();
            }

            if (newRssFeeds.Count == 0)
            {
                // There were no suitable feeds, hence get default feeds from resources.
                System.Diagnostics.Debug.Print("There were no suitable feeds, hence get default feeds from resources.");
                RssFeed rssFeed = RssFeed.FromText(Properties.Resources.DefaultRSSText);
                newRssFeeds.Add(rssFeed);
            }

            this.rssFeeds = newRssFeeds;
            // reset current indexes
            currentFeedIndex = -1;
            currentItemIndex = -1;
            MoveNext();
            lastRefresh = loadstart;
        }