5 people like it.

Recursively find all files from a sequence of directories

A function that will take a sequence of directory names and return a sequence of all file names within.

1: 
2: 
3: 
open System.IO
let allFilesInFolderList pattern folders = 
    folders |> Seq.collect (fun folder -> Directory.EnumerateFiles(folder, pattern, SearchOption.AllDirectories))
namespace System
namespace System.IO
val allFilesInFolderList : pattern:string -> folders:seq<string> -> seq<string>
val pattern : string
val folders : seq<string>
module Seq

from Microsoft.FSharp.Collections
val collect : mapping:('T -> #seq<'U>) -> source:seq<'T> -> seq<'U>
val folder : string
type Directory =
  static member CreateDirectory : path: string -> DirectoryInfo
  static member Delete : path: string -> unit + 1 overload
  static member EnumerateDirectories : path: string -> IEnumerable<string> + 3 overloads
  static member EnumerateFileSystemEntries : path: string -> IEnumerable<string> + 3 overloads
  static member EnumerateFiles : path: string -> IEnumerable<string> + 3 overloads
  static member Exists : path: string -> bool
  static member GetCreationTime : path: string -> DateTime
  static member GetCreationTimeUtc : path: string -> DateTime
  static member GetCurrentDirectory : unit -> string
  static member GetDirectories : path: string -> string [] + 3 overloads
  ...
Directory.EnumerateFiles(path: string) : System.Collections.Generic.IEnumerable<string>
Directory.EnumerateFiles(path: string, searchPattern: string) : System.Collections.Generic.IEnumerable<string>
Directory.EnumerateFiles(path: string, searchPattern: string, enumerationOptions: EnumerationOptions) : System.Collections.Generic.IEnumerable<string>
Directory.EnumerateFiles(path: string, searchPattern: string, searchOption: SearchOption) : System.Collections.Generic.IEnumerable<string>
type SearchOption =
  | TopDirectoryOnly = 0
  | AllDirectories = 1
field SearchOption.AllDirectories: SearchOption = 1
Raw view Test code New version

More information

Link:http://fssnip.net/8ap
Posted:10 months ago
Author:Shankar Velayudhan
Tags: list files recursive