How to fetch child tasks of subproject

I am using following code to get children of tasks. Now if my parent task is subproject then I do not get it’s children. But I can view children of subproject in MPP file.

TaskCollection children = parentTask.getChildren();
Iterator iterator = children.iterator();

@ketaki2092,

Could you please share such a sample file for investigation at our end? Unfortunately, we are not able to generate such a sample due to unknown reason. It will help us analyse the requirement and assist you further.

SampleMPP.zip (50.9 KB)
I have Uploaded zip file that contains two MPP files.01_Parent.mpp file is added as sub-project in 02_Child.mpp. If we open 02_Child.mpp file we can view tasks present in 01_parent.mpp but when we try to fetch all tasks of 02_Child.mpp using method mentioned above we cannot get it.

Please let me know what am I missing at earliest.

@ketaki2092,

Thank you for providing the sample project files. Following sample code can be used to fetch the tasks from a sub-project. Please give it a try and share the feedback.

static void TestSUbProject()
{
    Project proj = new Project(@"02_Child.mpp");
    DisplayTasks(proj);
}                
static void DisplayTasks(Project proj)
{
    TaskCollection tskCol = proj.RootTask.Children;
    foreach (var task in tskCol)
    {
        if (task.Get(Tsk.IsSubproject) == true)
        {
            Project proj2 = new Project(task.Get(Tsk.SubprojectName));
            DisplayTasks(proj2);
        }
        else
        {
            Console.WriteLine(task.Get(Tsk.Name));
        }
    }
}