Aspose.Words.Examples.CSharp.Programming_Documents.Comments.ProcessComments.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            // ExStart:ProcessComments
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithComments();
            string fileName = "TestFile.doc";

            // Open the document.
            Document doc = new Document(dataDir + fileName);

            // Extract the information about the comments of all the authors.
            foreach (string comment in ExtractComments(doc))
                Console.Write(comment);

            // Remove comments by the "pm" author.
            RemoveComments(doc, "pm");
            Console.WriteLine("Comments from \"pm\" are removed!");

            // Extract the information about the comments of the "ks" author.
            foreach (string comment in ExtractComments(doc, "ks"))
                Console.Write(comment);

            // Remove all comments.
            RemoveComments(doc);
            Console.WriteLine("All comments are removed!");

            dataDir = dataDir + RunExamples.GetOutputFilePath(fileName);
            // Save the document.
            doc.Save(dataDir);
            // ExEnd:ProcessComments
            Console.WriteLine("\nComments extracted and removed successfully.\nFile saved at " + dataDir);
        }
        // ExStart:ExtractComments