• Lexical
Show / Hide Table of Contents
  • Lexical.FileSystem
    • Introduction
    • Abstractions
      • IFileSystem
        • IFileSystem
        • IFileSystemBrowse
        • IFileSystemCreateDirectory
        • IFileSystemDelete
        • IFileSystemFileAttribute
        • IFileSystemMount
        • IFileSystemMove
        • IFileSystemObserve
        • IFileSystemOpen
      • IEvent
      • IEntry
      • IOption
      • IToken
    • FileSystem
    • VirtualFileSystem
    • MemoryFileSystem
    • EmbeddedFileSystem
    • HttpFileSystem
    • Decoration
    • IFileProvider
    • Utility
      • DisposeList
      • FileScanner
      • VisitTree
      • File Operation
  • Lexical.FileProvider
    • Introduction
    • Package
    • Package.Abstractions
    • Root
    • Zip
    • Dll
    • SharpCompress
    • SharpZipLib
    • FileScanner
    • Utils
  • Lexical.Localization
    • Introduction
    • Tutorial
    • Asset
      • IAsset
      • IStringAsset
    • Line
      • ILine
      • ILineFactory
      • ILineRoot
      • ILineFormat
      • ILineLogger
      • LineComparer
    • File
      • ILineReader
      • ILineWriter
      • Ini
      • Json
      • Xml
      • Resx
      • Resources
    • Miscellaneous
      • Plurality
      • ICulturePolicy
      • IStringFormat
      • Dependency Injection
    • Practices
      • Class Library
      • Class Library DI
      • Class Library DI opt.
  • Lexical.Utilities
    • Introduction
    • UnicodeString
    • FileScanner
    • Permutation
    • Tuples
    • StructList

Lexical.FileProviders.Utils

Lexical.FileProviders.Utils is a namespace that introduces extension methods.

Extension method .ListAllPaths() visits IFileProvider and returns all subpaths. This method uses one thread.

// Scan all subpaths
foreach (string subpath in fileProvider.ListAllPaths())
    Console.WriteLine(subpath);

Extension method .ListAll() visits IFileProvider and returns all IFileInfos.

// Scan all file infos
foreach (IFileInfo fi in fileProvider.ListAll())
    Console.WriteLine(fi.Name);

Extension method .ListAllFileInfoAndPath() visits IFileProvider and returns both subpath and IFileInfo in a tuple.

// Scan all file infos and their full subpaths
foreach ((IFileInfo, String) pair in fileProvider.ListAllFileInfoAndPath().OrderBy(pair => pair.Item2))
    Console.WriteLine(pair.Item2 + (pair.Item1.IsDirectory ? "/" : ""));

Links

  • Lexical.FileProvider.Utils (NuGet, Git)
  • Microsoft.Extensions.FileProviders.Abstractions (NuGet)
    • IFileProvider
Back to top Copyright © 2015-2020 Toni Kalajainen