Example #1
0
 /// <summary>
 /// Attach all local drives to <see cref="TreeItemVMs"/>. This method should be called at the startup of application.
 /// </summary>
 public void GetLocalDrives()
 {
     string[] drivePaths = null;
     try {
         drivePaths = Directory.GetLogicalDrives();
     } catch (UnauthorizedAccessException ex) {
         MessageBox.Show(ex.Message);
     }
     foreach (var drivePath in drivePaths)
     {
         var item = LocalItemFactory.Create(drivePath);
         TreeItemVMs.Add(new ItemVM(item));
         CurrentItemVMs.Add(new ItemVM(item));
     }
 }
Example #2
0
        public async IAsyncEnumerable <IItem> GetChildrenAsync()
        {
            IEnumerable <string> paths;

            try {
                paths = Directory.GetFiles(FullPath).Concat(Directory.GetDirectories(FullPath));
            } catch (UnauthorizedAccessException ex) {
                MessageBox.Show(ex.Message);
                yield break;
            } catch (IOException ex) {
                MessageBox.Show(ex.Message);
                yield break;
            }
            foreach (var path in paths)
            {
                yield return(LocalItemFactory.Create(path));
            }
        }