There is EnvironmentManager.Instance.MasterSite; ref. https://doc.developer.milestonesys.com/html/index.html?base=miphelp/class_video_o_s_1_1_platform_1_1_environment_manager.html&tree=tree_search.html?search=mastersite
It is possible to have multiple sites if using Milestone Federated Architecture (MFA). This is perhaps a special case but if you want to have your integration ready for MFA you should consider the possibility.
var site = EnvironmentManager.Instance.GetSiteItem(EnvironmentManager.Instance.MasterSite);
ShowWithChildren(site);
private void ShowWithChildren(Item item)
{
if (item.FQID.Kind == Kind.Server)
{
label1.Text += item.FQID.ToString() + Environment.NewLine;
foreach (var item2 in item.GetChildren())
{
ShowWithChildren(item2);
}
}
}