File

Functions and values

Function or valueDescription
File.allExist(files)
Signature: files:seq<string> -> bool

Checks if all given files exist.

File.append file lines
Signature: file:string -> lines:seq<string> -> unit

Appends all lines to a file line by line

File.applyReplace replaceF fileName
Signature: replaceF:(string -> string) -> fileName:string -> unit

Replaces the text in the given file

File.checkExists(fileName)
Signature: fileName:string -> unit

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

File.create(fileName)
Signature: fileName:string -> unit

Creates a file if it does not exist.

File.delete(fileName)
Signature: fileName:string -> unit

Deletes a file if it exists.

File.deleteAll(files)
Signature: files:seq<string> -> unit

Deletes the given files.

File.exists(fileName)
Signature: fileName:string -> bool

Checks if the file exists on disk.

File.getEncoding def filename
Signature: def:Encoding -> filename:string -> Encoding
File.getEncodingOrDefault def filename
Signature: def:Encoding -> filename:string -> Encoding

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

File.getEncodingOrUtf8WithoutBom
Signature: string -> Encoding

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

File.getVersion(fileName)
Signature: fileName:string -> string

Get the version a file.

Parameters

  • 'fileName' - Name of file from which the version is retrieved. The path can be relative.
File.read(file)
Signature: file:string -> seq<string>
File.readAsBytes(file)
Signature: file:string -> byte []

Reads a file as one array of bytes

File.readAsString(file)
Signature: file:string -> string
File.readAsStringWithEncoding(...)
Signature: encoding:Encoding -> file:string -> string

Reads a file as one text

File.readLine(file)
Signature: file:string -> string

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

File.readLineWithEncoding encoding file
Signature: encoding:Encoding -> file:string -> string

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

File.readWithEncoding encoding file
Signature: encoding:Encoding -> file:string -> seq<string>

Reads a file line by line

File.replaceContent fileName text
Signature: fileName:string -> text:string -> unit

Replaces the file with the given string

File.write append fileName lines
Signature: append:bool -> fileName:string -> lines:seq<string> -> unit
File.writeBytes file bytes
Signature: file:string -> bytes:byte [] -> unit

Writes a byte array to a file

File.writeNew file lines
Signature: file:string -> lines:seq<string> -> unit

Writes a file line by line

File.writeString append fileName text
Signature: append:bool -> fileName:string -> text:string -> unit
File.writeStringWithEncoding(...)
Signature: encoding:Encoding -> append:bool -> fileName:string -> text:string -> unit

Writes a string to a file

File.writeWithEncoding(...)
Signature: encoding:Encoding -> append:bool -> fileName:string -> lines:seq<string> -> unit

Writes a file line by line

Active patterns

Active patternDescription
File.( |EndsWith|_| ) extension file
Signature: extension:string -> file:string -> unit option

Active Pattern for determining file extension.