Note: This API documentation is for FAKE version 4. The migration API documentation can be found here. The API documentation for the new fake 5 modules can be found here

FileSystemHelper

Contains helpers which allow to interact with the file system.

Functions and values

Function or valueDescription
allFilesExist(files)
Signature: files:seq<string> -> bool

Checks if all given files exist.

checkFileExists(fileName)
Signature: fileName:string -> unit

Raises an exception if the file doesn't exist on disk.

currentDirectory
Signature: string

Gets the current directory.

directoryExists(dir)
Signature: dir:string -> bool

Checks if the directory exists on disk.

directoryInfo(path)
Signature: path:string -> DirectoryInfo

Creates a DirectoryInfo for the given path.

DirectoryName(fileName)
Signature: fileName:string -> string

Gets the directory part of a filename.

ensureDirectory(dir)
Signature: dir:string -> unit

Checks if the given directory exists. If not then this functions creates the directory.

ensureDirExists(dir)
Signature: dir:DirectoryInfo -> unit

Ensure that directory chain exists. Create necessary directories if necessary.

fileExists(fileName)
Signature: fileName:string -> bool

Checks if the file exists on disk.

fileInfo(path)
Signature: path:string -> FileInfo

Creates a FileInfo for the given path.

filesInDir(dir)
Signature: dir:DirectoryInfo -> FileInfo []

Gets all files in the directory.

filesInDirMatching pattern dir
Signature: pattern:string -> dir:DirectoryInfo -> FileInfo []

Finds all the files in the directory matching the search pattern.

filesInDirMatchingRecursive pattern dir
Signature: pattern:string -> dir:DirectoryInfo -> FileInfo []

Finds all the files in the directory and in all subdirectories matching the search pattern.

fileSystemInfo(path)
Signature: path:string -> FileSystemInfo

Creates a FileInfo or a DirectoryInfo for the given path

FindFirstMatchingFile pattern dir
Signature: pattern:string -> dir:string -> string

Gets the first file in the directory matching the search pattern or throws an error if nothing was found.

fullAssemblyPath
Signature: string

Get the full location of the current assembly.

FullName(fileName)
Signature: fileName:string -> string

Converts a filename to it's full file system name.

isDirectory(path)
Signature: path:string -> bool

Detects whether the given path is a directory.

isFile(path)
Signature: path:string -> bool

Detects whether the given path is a file.

isInFolder dir fileInfo
Signature: dir:DirectoryInfo -> fileInfo:FileInfo -> bool

Checks if the file is in a subfolder of the dir.

isSubfolderOf dir2 dir1
Signature: dir2:DirectoryInfo -> dir1:DirectoryInfo -> bool

Checks if dir1 is a subfolder of dir2. If dir1 equals dir2 the function returns also true.

isValidPath(path)
Signature: path:string -> bool

Detects whether the given path does not contains invalid characters.

normalizeFileName(fileName)
Signature: fileName:string -> string

Normalizes a filename.

subDirectories(dir)
Signature: dir:DirectoryInfo -> DirectoryInfo []

Gets all subdirectories of a given directory.

TryFindFirstMatchingFile pattern dir
Signature: pattern:string -> dir:string -> string option

Gets the first file in the directory matching the search pattern as an option value.