1 people like it.
Like the snippet!
Are Files Present In A Directory?
A quick and dirty function to check to see if there are files present in a directory. Note this will return false if there are only subdirs in a directory.
1:
2:
3:
4:
5:
6:
|
open System.IO
let FilesPresentInDirectory basePath =
let countOfSubDirs = Directory.GetDirectories(basePath) |> Seq.length
let countOfFiles = Directory.EnumerateFileSystemEntries(basePath) |> Seq.length
countOfFiles > countOfSubDirs
|
namespace System
namespace System.IO
val FilesPresentInDirectory : basePath:string -> bool
Full name: Script.FilesPresentInDirectory
val basePath : string
val countOfSubDirs : int
type Directory =
static member CreateDirectory : path:string -> DirectoryInfo + 1 overload
static member Delete : path:string -> unit + 1 overload
static member EnumerateDirectories : path:string -> IEnumerable<string> + 2 overloads
static member EnumerateFileSystemEntries : path:string -> IEnumerable<string> + 2 overloads
static member EnumerateFiles : path:string -> IEnumerable<string> + 2 overloads
static member Exists : path:string -> bool
static member GetAccessControl : path:string -> DirectorySecurity + 1 overload
static member GetCreationTime : path:string -> DateTime
static member GetCreationTimeUtc : path:string -> DateTime
static member GetCurrentDirectory : unit -> string
...
Full name: System.IO.Directory
Directory.GetDirectories(path: string) : string []
Directory.GetDirectories(path: string, searchPattern: string) : string []
Directory.GetDirectories(path: string, searchPattern: string, searchOption: SearchOption) : string []
module Seq
from Microsoft.FSharp.Collections
val length : source:seq<'T> -> int
Full name: Microsoft.FSharp.Collections.Seq.length
val countOfFiles : int
Directory.EnumerateFileSystemEntries(path: string) : System.Collections.Generic.IEnumerable<string>
Directory.EnumerateFileSystemEntries(path: string, searchPattern: string) : System.Collections.Generic.IEnumerable<string>
Directory.EnumerateFileSystemEntries(path: string, searchPattern: string, searchOption: SearchOption) : System.Collections.Generic.IEnumerable<string>
More information