Deleting all RSS feeds in IE7

Wed, August 2, 2006, 02:46 PM under IE7 RSS

We already looked at how I deleted all the feeds in Outlook 2007 in one go, and not one by one.

Luckily IE7 understands folder structures from opml but somehow I managed to get them all in a flat list in IE as well (probably outlook messed that up for me or maybe a glitch with IE7 Beta 2 that I was using or something else, not important now).

So how do you delete all feeds in IE7? Out of the box you can't. Fastest end user way would be to create a folder and drag them all in it one-by-one and then delete the folder - yuck!

Another way is to be stupid and delete the contents of the Windows RSS Platform store directly (after shutting down all apps that use it, including IE7 of course). The feed store currently (Beta 3) is here:
"[drive letter]:\Documents and Settings\[user name]\Local Settings\Application Data\Microsoft\Feeds\[your feeds and folders]"

For me however, this was the opportunity I needed to test drive the RSS API. Unfortunately, it is so easy to use that I could achieve what I wanted with a dozen lines of code so here is my simple effort:

using Microsoft.Feeds.Interop;

class Program
{
static void Main(string[] args)
{
IFeedsManager fm = new FeedsManagerClass();
IFeedFolder ff = (IFeedFolder)fm.RootFolder;
System.Console.WriteLine("Starting deletion at root");
DeleteFolder(ff);

System.Console.WriteLine("Deleted all feeds!");
System.Console.ReadLine();
}
private static void DeleteFolder(IFeedFolder ff)
{
DeleteFeedsInFolder(ff);
System.Console.WriteLine();

foreach (IFeedFolder sf in (IFeedsEnum)ff.Subfolders)
{
System.Console.WriteLine("Deleting subfolder '{0}'", sf.Name);
//DeleteFolder(sf); //not needed really but it can demo recursion
sf.Delete();
}
}
private static void DeleteFeedsInFolder(IFeedFolder ff)
{
foreach (IFeed feed in (IFeedsEnum)ff.Feeds)
{
System.Console.WriteLine("Deleting feed {0}", feed.Name);
feed.Delete();
}
}
}
Also note that the code should explicitly release the COM objects. In other words, wherever you have a reference to an object, when you are done with it call:

System.Runtime.InteropServices.Marshal.ReleaseComObject(f);