Пример #1
0
        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));
                }
            }
        }
Пример #3
0
        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);
        }
Пример #4
0
        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));
                }
            }
        }
Пример #5
0
        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));
            }
        }