Aspose.Tasks.Examples.CSharp.WorkingWithTasks.MoveTaskUnderAnotherParent.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {        
            try
            {
                // ExStart:MoveTaskUnderAnotherParent
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);  

                // Loading project file
                Project project = new Project(dataDir + "MoveTask.mpp");

                // Set CalculationMode
                project.CalculationMode = CalculationMode.Automatic;
              
                // Get Tasks by Ids
                Task t6 = project.RootTask.Children.GetByUid(6);
                Task t3 = project.RootTask.Children.GetByUid(3);

                // Adding Task 6 to another parent
                t3.Children.Add(t6);

                // Saving File To Disk
                project.Save(dataDir + "MoveTaskUnderAnotherParent_out.mpp", SaveFileFormat.MPP);
                // ExEnd:MoveTaskUnderAnotherParent
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message + "\nThis example will only work if you apply a valid Aspose.Tasks License. You can purchase full license or get 30 day temporary license from http://www.aspose.com/purchase/default.aspx.");  
            }
        }
    }
MoveTaskUnderAnotherParent