See the question and my original answer on StackOverflow

You could use the Html Agility Pack .NET library. Here is an article that explains how to use it on SO: How to use HTML Agility pack

This is the C# code to remove comments:

    HtmlDocument doc = new HtmlDocument();
    doc.Load("yourFile.htm");

    // get all comment nodes using XPATH
    foreach (HtmlNode comment in doc.DocumentNode.SelectNodes("//comment()"))
    {
        comment.ParentNode.RemoveChild(comment);
    }
    doc.Save(Console.Out); // displays doc w/o comments on console