Aspose.Plugins.AsposeVSOpenXML.Program.RemoveComments C# (CSharp) Method

RemoveComments() public static method

public static RemoveComments ( string File, string authorName ) : void
File string
authorName string
return void
        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);
        }
    }