CreateFromEntry() public static méthode

public static CreateFromEntry ( string filesystemPath, string name ) : FilesystemFileInfo
filesystemPath string
name string
Résultat FilesystemFileInfo
Exemple #1
0
        public void EnumerateFiles(Package package, string rootPath, string currentPath)
        {
            foreach (string filePath in Directory.GetFiles(currentPath))
            {
                var relativePath = filePath.Substring(rootPath.Length);
                if (relativePath[0] == '/' || relativePath[0] == '\\')
                {
                    relativePath = relativePath.Substring(1);
                }

                var fileInfo = FilesystemFileInfo.CreateFromEntry(filePath, relativePath);
                package.Files.Add(fileInfo);
            }

            foreach (string directoryPath in Directory.GetDirectories(currentPath))
            {
                EnumerateFiles(package, rootPath, directoryPath);
            }
        }
Exemple #2
0
        private static Package CreatePackageFromPath(string path)
        {
            var package = new Package();

            if (!path.EndsWith(Path.DirectorySeparatorChar.ToString()))
            {
                path += Path.DirectorySeparatorChar;
            }

            Dictionary <string, string> files = Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories)
                                                .ToDictionary(k => k.Replace(path, String.Empty), v => v);

            foreach (KeyValuePair <string, string> file in files)
            {
                FilesystemFileInfo fileInfo = FilesystemFileInfo.CreateFromEntry(file.Value, file.Key);
                package.Files.Add(fileInfo);
            }

            return(package);
        }