Skip to content

ReadTextFile (read a text file)

ts
function ReadTextFile(what: string): string;

This function reads the what text file and returns its entire contents as a string. If the file doesn’t exist or if the operating system returns an I/O error, this function returns an empty string.

This function accepts the following parameters:

ParameterTypeRequirementExplanation
whatstringrequiredmust be a valid and existing path to a file you wish to read

Return value:

TypeExplanation
stringthe entire contents of the file as a single string (may contain weird/unpredictable characters if you attempt to read a binary file)