0 people like it.

EnumerateDirectoryFilesInfo

the function returns entire files sequence for given root directory, including sub-directories.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
module Program

open System.IO

let EnumerateDirectoryFilesInfo root = 
    let rec traverse (d: DirectoryInfo) = 
        seq {   for f in d.GetFiles() do
                    yield f
                for dd in d.GetDirectories() do
                    yield! traverse dd              }
    traverse (DirectoryInfo( root ))
    
EnumerateDirectoryFilesInfo @"C:\Temp\Input"
|> Seq.iter( fun f -> printfn "%s" f.FullName )
module Program
namespace System
namespace System.IO
val EnumerateDirectoryFilesInfo : root:string -> seq<FileInfo>

Full name: Program.EnumerateDirectoryFilesInfo
val root : string
val traverse : (DirectoryInfo -> seq<FileInfo>)
val d : DirectoryInfo
Multiple items
type DirectoryInfo =
  inherit FileSystemInfo
  new : path:string -> DirectoryInfo
  member Create : unit -> unit + 1 overload
  member CreateSubdirectory : path:string -> DirectoryInfo + 1 overload
  member Delete : unit -> unit + 1 overload
  member EnumerateDirectories : unit -> IEnumerable<DirectoryInfo> + 2 overloads
  member EnumerateFileSystemInfos : unit -> IEnumerable<FileSystemInfo> + 2 overloads
  member EnumerateFiles : unit -> IEnumerable<FileInfo> + 2 overloads
  member Exists : bool
  member GetAccessControl : unit -> DirectorySecurity + 1 overload
  member GetDirectories : unit -> DirectoryInfo[] + 2 overloads
  ...

Full name: System.IO.DirectoryInfo

--------------------
DirectoryInfo(path: string) : unit
Multiple items
val seq : sequence:seq<'T> -> seq<'T>

Full name: Microsoft.FSharp.Core.Operators.seq

--------------------
type seq<'T> = System.Collections.Generic.IEnumerable<'T>

Full name: Microsoft.FSharp.Collections.seq<_>
val f : FileInfo
DirectoryInfo.GetFiles() : FileInfo []
DirectoryInfo.GetFiles(searchPattern: string) : FileInfo []
DirectoryInfo.GetFiles(searchPattern: string, searchOption: SearchOption) : FileInfo []
val dd : DirectoryInfo
DirectoryInfo.GetDirectories() : DirectoryInfo []
DirectoryInfo.GetDirectories(searchPattern: string) : DirectoryInfo []
DirectoryInfo.GetDirectories(searchPattern: string, searchOption: SearchOption) : DirectoryInfo []
module Seq

from Microsoft.FSharp.Collections
val iter : action:('T -> unit) -> source:seq<'T> -> unit

Full name: Microsoft.FSharp.Collections.Seq.iter
val printfn : format:Printf.TextWriterFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
property FileSystemInfo.FullName: string
Raw view New version

More information

Link:http://fssnip.net/en
Posted:6 years ago
Author:Michael Gringauz
Tags: i/o , directory , tree , traverse