Skip to content

File.Exists

method · File · cAlgo.API Since 5.7

DesktopCLICloud

Returns True if File exists otherwise False.

Environment behaviour

Cloud — not supported. Exists returns false; reads return empty string/array; writes and appends silently do nothing. No exception.

Definition

bool Exists()
file.Exists() -> bool

Returns bool — bool

Examples

protected override void OnStart()
{
    if (!DataFile.Exists())
        DataFile.WriteAllText("Symbol,Price");
}
if not api.DataFile.Exists():
    api.DataFile.WriteAllText("Symbol,Price")
{
  "Parameters": [
    {
      "Name": "DataFile",
      "DisplayName": "Data File",
      "Type": "File"
    }
  ]
}