Exemple #1
0
        public void ListDirectoriesGetsDirectoriesByMask()
        {
            Directory.CreateDirectory("foo");
            Directory.CreateDirectory("foo\\dir1");
            Directory.CreateDirectory("foo\\dir2");
            var dirs = _search.ListDirs("foo", "di").ToList();

            Assert.AreEqual(2, dirs.Count);
            Assert.AreEqual("dir1", dirs[0].Name);
            Assert.AreEqual("dir2", dirs[1].Name);
        }
        public void ListDirectory()
        {
            var dirs   = new List <OpenFolderViewModel>();
            var curDir = new DirectoryInfo(ViewModel.Directory);

            if (curDir.Parent == null)
            {
                foreach (var drive in Environment.GetLogicalDrives())
                {
                    dirs.Add(new OpenFolderViewModel(drive, new DirectoryInfo(drive)));
                }
            }
            else
            {
                dirs.Add(new OpenFolderViewModel("..", curDir.Parent));
            }
            dirs.AddRange(_directorySearch.ListDirs(ViewModel.Directory, string.Empty)
                          .Select(d => new OpenFolderViewModel(d.Name, d)));
            ViewModel.Directories = dirs;
        }