private void OpenDirectory() { DirectoriesAndFiles.Clear(); if (Name == "Мой компьютер") { foreach (var logicalDrive in Directory.GetLogicalDrives()) { DirectoriesAndFiles.Add(new DirectoryViewModel(logicalDrive)); } return; } var directoryInfo = new DirectoryInfo(FilePath); foreach (var directory in directoryInfo.GetDirectories()) { DirectoriesAndFiles.Add(new DirectoryViewModel(directory)); } foreach (var fileInfo in directoryInfo.GetFiles()) { DirectoriesAndFiles.Add(new FileViewModel(fileInfo)); } }
private void OpenDirectory() { DirectoriesAndFiles.Clear(); if (Name == "My computer") { foreach (var drive in Directory.GetLogicalDrives()) { DirectoriesAndFiles.Add(new DirectoryViewModel(drive)); } } else { var directoryInfo = new DirectoryInfo(FilePath); foreach (var directory in directoryInfo.GetDirectories()) { DirectoriesAndFiles.Add(new DirectoryViewModel(directory)); } foreach (var file in directoryInfo.GetFiles()) { DirectoriesAndFiles.Add(new FileViewModel(file)); } } }
private void RunWorker() { DirectoriesAndFiles.Clear(); if (Name == "Мой компьютер") { foreach (var logicalDrive in Directory.GetLogicalDrives()) { DirectoriesAndFiles.Add(new DirectoryViewModel(logicalDrive)); } return; } var directoryInfo = new DirectoryInfo(FilePath); _backgroundWorker.RunWorkerAsync(directoryInfo); }
private void Open(object parameter) { if (parameter is DirectoryViewModel dirViewModel) { FilePath = dirViewModel.FullName; DirectoriesAndFiles.Clear(); var dirInfo = new DirectoryInfo(FilePath); foreach (var dir in dirInfo.GetDirectories()) { DirectoriesAndFiles.Add(new DirectoryViewModel(dir)); } foreach (var fileInfo in dirInfo.GetFiles()) { DirectoriesAndFiles.Add(new FileViewModel(fileInfo)); } } }
private void OpenDirectory() { DirectoriesAndFiles.Clear(); var directoryInfo = new DirectoryInfo(FilePath); foreach (var directory in directoryInfo.GetDirectories()) { if (!directory.Attributes.HasFlag(FileAttributes.Hidden)) { DirectoriesAndFiles.Add(new DirectoryViewModel(directory)); } } foreach (var fileInfo in directoryInfo.GetFiles()) { DirectoriesAndFiles.Add(new FileViewModel(fileInfo)); } }