public async Task RefreshAsync(CancellationToken cancellationToken, int initialRealizedFileSystemTreeLevels = defaultInitializationDepth) { if (initialRealizedFileSystemTreeLevels < 1) { throw new ArgumentOutOfRangeException("Level count can't be smaller than 1"); } InternalDrives.Clear(); FileSystemMount.ChildFileSystemItems.Clear(); InternalFileSystemRoot.Clear(); await InitializeFileSystemTreeAsync(cancellationToken, initialRealizedFileSystemTreeLevels); }
public async Task InitializeFileSystemTreeAsync(CancellationToken cancellationToken, int initialRealizedFileSystemTreeLevels = defaultInitializationDepth, bool isSortingEnabled = false) { if (initialRealizedFileSystemTreeLevels < 1) { throw new ArgumentOutOfRangeException("Level count can't be smaller than 1"); } await Task.Run(() => { foreach (DriveInfo drive in DriveInfo.GetDrives()) { InternalDrives.Add(drive); } var rootItems = CreateFileSystemRootItems(InternalDrives, cancellationToken); foreach (IFileSystemItemModel rootItem in rootItems) { FileSystemMount.ChildFileSystemItems.Add(rootItem); InternalFileSystemRoot.Add(rootItem); } RealizeFromRoot(initialRealizedFileSystemTreeLevels, cancellationToken, isSortingEnabled); }, cancellationToken); }