FileAliases.

FileExists(ICakeContext, FilePath) Method

Summary

Determines whether the given path refers to an existing file.
Namespace
Cake.Common.IO
Containing Type
FileAliases

Syntax

[CakeMethodAlias]
[CakeAliasCategory("Exists")]
public static bool FileExists(this ICakeContext context, FilePath filePath)

Examples

if (FileExists("findme.txt"))
{
    Information("File exists!");
}

Attributes

Type Description
CakeMethodAliasAttribute An attribute used to mark script method aliases.
CakeAliasCategoryAttribute An attribute used for documentation of alias methods/properties.

Parameters

Name Type Description
context ICakeContext The context.
filePath FilePath The FilePath to check.

Return Value

Type Description
bool true if filePath refers to an existing file; false if the file does not exist or an error occurs when trying to determine if the specified file exists.