FAKE - F# Make - A DSL for build tasks and more FAKE
6.1.3

Lookig for older versions of the documentation, pre FAKE v6? See 

v5.fake.build

File Module

Contains helpers which allow to interact with the file system.

Functions and values

Function or value Description

File.allExist files

Full Usage: File.allExist files

Parameters:
    files : seq<string> - The files names to check

Returns: bool

Checks if all given files exist.

files : seq<string>

The files names to check

Returns: bool

File.append file lines

Full Usage: File.append file lines

Parameters:
    file : string - The file name to use
    lines : seq<string> - The lines to append

Appends all lines to a file line by line

file : string

The file name to use

lines : seq<string>

The lines to append

File.applyReplace replaceF fileName

Full Usage: File.applyReplace replaceF fileName

Parameters:
    replaceF : string -> string - The callback to execute when replacing content
    fileName : string - The file name to use

Replaces the text in the given file

replaceF : string -> string

The callback to execute when replacing content

fileName : string

The file name to use

File.checkExists fileName

Full Usage: File.checkExists fileName

Parameters:
    fileName : string

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

fileName : string

File.create fileName

Full Usage: File.create fileName

Parameters:
    fileName : string - The name of the file to create

Creates a file if it does not exist.

fileName : string

The name of the file to create

File.delete fileName

Full Usage: File.delete fileName

Parameters:
    fileName : string - The name of the file to delete

Deletes a file if it exists.

fileName : string

The name of the file to delete

File.deleteAll files

Full Usage: File.deleteAll files

Parameters:
    files : seq<string> - The name of the files to delete

Deletes the given files.

files : seq<string>

The name of the files to delete

File.exists fileName

Full Usage: File.exists fileName

Parameters:
    fileName : string - The file name to check

Returns: bool

Checks if the file exists on disk.

fileName : string

The file name to check

Returns: bool

File.getEncoding def filename

Full Usage: File.getEncoding def filename

Parameters:
    def : Encoding - The encoding to detect for
    filename : string - The file name to check

Returns: Encoding

Detect the encoding, from https://stackoverflow.com/questions/3825390/effective-way-to-find-any-files-encoding Detect the encoding

def : Encoding

The encoding to detect for

filename : string

The file name to check

Returns: Encoding

File.getEncodingOrDefault def filename

Full Usage: File.getEncodingOrDefault def filename

Parameters:
    def : Encoding - The encoding to detect for
    filename : string - The file name to check

Returns: Encoding

Gets the encoding from the file or the default of the file doesn't exist

def : Encoding

The encoding to detect for

filename : string

The file name to check

Returns: Encoding

File.getEncodingOrUtf8WithoutBom

Full Usage: File.getEncodingOrUtf8WithoutBom

Returns: string -> Encoding

Get the encoding from the file or utf8 without BOM if unknown or the file doesn't exist

Returns: string -> Encoding

File.getVersion fileName

Full Usage: File.getVersion fileName

Parameters:
    fileName : string - Name of file from which the version is retrieved. The path can be relative.

Returns: string

Get the version a file. This overload throws when the file has no version, consider using `tryGetVersion` instead. On non-windows platforms this API returns assembly metadata instead, FileVersionInfo.Unix.cs

fileName : string

Name of file from which the version is retrieved. The path can be relative.

Returns: string

File.read file

Full Usage: File.read file

Parameters:
    file : string

Returns: seq<string>
file : string
Returns: seq<string>

File.readAsBytes file

Full Usage: File.readAsBytes file

Parameters:
    file : string - The file name to use

Returns: byte[]

Reads a file as one array of bytes

file : string

The file name to use

Returns: byte[]

File.readAsString file

Full Usage: File.readAsString file

Parameters:
    file : string - The file name to use

Returns: string
Modifiers: inline

Reads a file as one text

file : string

The file name to use

Returns: string

File.readAsStringWithEncoding encoding file

Full Usage: File.readAsStringWithEncoding encoding file

Parameters:
    encoding : Encoding - The encoding to use
    file : string - The file name to use

Returns: string
Modifiers: inline

Reads a file as one text

encoding : Encoding

The encoding to use

file : string

The file name to use

Returns: string

File.readLine file

Full Usage: File.readLine file

Parameters:
    file : string - The file name to use

Returns: string

Reads the first line of a file. This can be helpful to read a password from file.

file : string

The file name to use

Returns: string

File.readLineWithEncoding encoding file

Full Usage: File.readLineWithEncoding encoding file

Parameters:
    encoding : Encoding - The encoding to use
    file : string - The file name to use

Returns: string

Reads the first line of a file. This can be helpful to read a password from file.

encoding : Encoding

The encoding to use

file : string

The file name to use

Returns: string

File.readWithEncoding encoding file

Full Usage: File.readWithEncoding encoding file

Parameters:
    encoding : Encoding - The encoding to use
    file : string - The file name to use

Returns: seq<string>

Reads a file line by line

encoding : Encoding

The encoding to use

file : string

The file name to use

Returns: seq<string>

File.replaceContent fileName text

Full Usage: File.replaceContent fileName text

Parameters:
    fileName : string
    text : string - The string text to write

Replaces the file with the given string

fileName : string
text : string

The string text to write

File.tryGetVersion fileName

Full Usage: File.tryGetVersion fileName

Parameters:
    fileName : string - Name of file from which the version is retrieved. The path can be relative.

Returns: string option

Tries to get the version of a file. Throws `FileNotFoundException` if the file doesn't exist. Returns None if the file doesn't contain a `FileVersion` component. On non-windows platforms this API returns assembly metadata instead, see FileVersionInfo.Unix.cs

fileName : string

Name of file from which the version is retrieved. The path can be relative.

Returns: string option

File.write append fileName lines

Full Usage: File.write append fileName lines

Parameters:
    append : bool - Flag to check if to append content or overwrite
    fileName : string
    lines : seq<string> - The lines to write

Write the given sequence of lines to the file. Either append to the end of the file or overwrite

append : bool

Flag to check if to append content or overwrite

fileName : string
lines : seq<string>

The lines to write

File.writeBytes file bytes

Full Usage: File.writeBytes file bytes

Parameters:
    file : string - The file name to use
    bytes : byte[] - The bytes to write

Writes a byte array to a file

file : string

The file name to use

bytes : byte[]

The bytes to write

File.writeNew file lines

Full Usage: File.writeNew file lines

Parameters:
    file : string - The file name to use
    lines : seq<string> - The lines to write

Writes a file line by line

file : string

The file name to use

lines : seq<string>

The lines to write

File.writeString append fileName text

Full Usage: File.writeString append fileName text

Parameters:
    append : bool - Flag to check if to append content or overwrite
    fileName : string
    text : string - The string text to write

Writes a string to a file

append : bool

Flag to check if to append content or overwrite

fileName : string
text : string

The string text to write

File.writeStringWithEncoding encoding append fileName text

Full Usage: File.writeStringWithEncoding encoding append fileName text

Parameters:
    encoding : Encoding - The encoding to use
    append : bool - Flag to check if to append content or overwrite
    fileName : string
    text : string - The string text to write

Writes a string to a file

encoding : Encoding

The encoding to use

append : bool

Flag to check if to append content or overwrite

fileName : string
text : string

The string text to write

File.writeWithEncoding encoding append fileName lines

Full Usage: File.writeWithEncoding encoding append fileName lines

Parameters:
    encoding : Encoding - The encoding to use
    append : bool - Flag to check if to append content or overwrite
    fileName : string
    lines : seq<string> - The lines to write

Writes a file line by line

encoding : Encoding

The encoding to use

append : bool

Flag to check if to append content or overwrite

fileName : string
lines : seq<string>

The lines to write

Active patterns

Active pattern Description

File.(|EndsWith|_|) extension file

Full Usage: File.(|EndsWith|_|) extension file

Parameters:
    extension : string - The extension to look for
    file : string - The file name to use

Returns: unit option

Active Pattern for determining file extension.

extension : string

The extension to look for

file : string

The file name to use

Returns: unit option