Пример #1
0
        public static IDirectoryViewModel ClearNotExistDirectories(IDirectoryViewModel directory)
        {
            IDirectoryViewModel noExistDirectory = null;
            IDirectoryViewModel currentDirectory = directory;

            while (currentDirectory.Parent != null)
            {
                if (currentDirectory.Path == "" || Directory.Exists(currentDirectory.Path))
                {
                    if (noExistDirectory != null)
                    {
                        currentDirectory.SubDirectories.Remove(noExistDirectory);
                    }
                    return(currentDirectory);
                }
                DirectoryWatcher.DeleteFileSystemWatcher(currentDirectory);
                currentDirectory.SubDirectories.Clear();
                currentDirectory.Files.Clear();
                noExistDirectory = currentDirectory;
                currentDirectory = currentDirectory.Parent;
            }
            // only this pc
            if (currentDirectory.Path == "")
            {
                if (noExistDirectory != null)
                {
                    currentDirectory.SubDirectories.Remove(noExistDirectory);
                }
                return(currentDirectory);
            }

            return(null);
        }
Пример #2
0
        private void DirectoryViewModelBaseOnNoExistDirectory(object sender, DirectoryViewModelBase.NoExistDirectoryArgs e)
        {
            var directory = PathHelper.ClearNotExistDirectories(e.Directory);

            e.Directory.Parent.SubDirectories.Remove(directory);
            DirectoryWatcher.DeleteFileSystemWatcher(e.Directory);
        }