private void Write(StringBuilder builder, bool relativeToRoot)
{
// This method is recursive. If we expect to see hierarchies
// so deep that it would cause us to overflow the stack, we could
// consider using an explicit stack object rather than recursion.
// This is unlikely, however, given typical directory names
// and max path limits.
// First append the parent's path
if (Parent != null)
{
Parent.Write(builder, relativeToRoot);
AppendSeparatorIfNeeded(builder);
}
// Then append ours. In the case of the root directory
// being watched, we only append its name if the caller
// has asked for a full path.
if (Parent != null || !relativeToRoot)
{
builder.Append(Name);
}
}