Beispiel #1
0
        // get all RELATIVE directories and files under a specific root
        // will skip dirs and files that start with ".", which is assumed to be hidden
        // *** TODO ***
        // This skip logic might be incorrect

        public static void GetRelativeDirsAndFiles(this IDirectoryManager manager,
                                                   string parentFullPath, string targetFullPath, out IEnumerable <string> relativeDirs, out IEnumerable <string> relativeFiles)
        {
            IEnumerable <string> fullPathDirs, fullPathFiles;

            try
            {
                manager.GetDirsAndFiles(targetFullPath, out fullPathDirs, out fullPathFiles);
            }
            catch (Exception)
            {
                relativeDirs = null; relativeFiles = null;
                throw;
            }

            relativeDirs = fullPathDirs
                           .Select(dir => GetRelativePath(parentFullPath, dir))
                           .Where(dir => !dir.StartsWith('.')).ToArray();

            relativeFiles = fullPathFiles
                            .Select(file => GetRelativePath(parentFullPath, file))
                            .Where(file => !file.StartsWith('.')).ToArray();
        }