public static void RemoveComments(string File, string authorName)
{
Document doc = new Document(File);
// Collect all comments in the document
NodeCollection comments = doc.GetChildNodes(NodeType.Comment, true);
if (authorName == "")
{
// Remove all comments.
comments.Clear();
}
else
{
// Look through all comments and remove those written by the authorName author.
for (int i = comments.Count - 1; i >= 0; i--)
{
Comment comment = (Comment)comments[i];
if (comment.Author == authorName)
comment.Remove();
}
}
doc.Save(File);
}
}