private static void PrintItem(IFileSystemItem item, StringBuilder builder, bool printRoot) { if (item.Kind == FileSystemItemKind.Root && !printRoot) { return; } void AppendIndent() { int itemLevel = item.GetLevel(); if (!printRoot) { itemLevel--; } if (itemLevel > 0) { for (int i = 0; i < itemLevel; i++) { builder.Append("| "); } builder[builder.Length - 1] = '_'; } } string GetItemKindDescription() { switch (item.Kind) { case FileSystemItemKind.Directory: return(" [DIR]"); case FileSystemItemKind.File: return(" [FILE]"); default: return(null); } } string GetLockedByDescription() { if (!item.IsLocked) { return(null); } var lockedByOrdered = item.LockedBy.OrderBy(userName => userName, UserNameComparer); return(Invariant($" [LOCKED BY: {string.Join(", ", lockedByOrdered)}]")); } if (builder.Length > 0) { builder.AppendLine(); } AppendIndent(); builder.Append(item.Name); builder.Append(GetItemKindDescription()); builder.Append(GetLockedByDescription()); }