Skip to content

File.AppendAllText

method · File · cAlgo.API Since 5.7

DesktopCLICloud

Append text to file.

Environment behaviour

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

Overloads

Signature Description
AppendAllText(string contents) Append text to file.
AppendAllText(string contents, EncodingType encodingType) Appends text to file that has a specified encoding.

AppendAllText(string contents)

Append text to file.

void AppendAllText(string contents)
file.AppendAllText(contents: str) -> None

Parameters

Name C# type Python type Description
contents string str The string to append to the file.

Examples

protected override void OnBar()
{
    DataFile.AppendAllText($"{Bars.LastBar.OpenTime:O},{Bars.LastBar.Close}{Environment.NewLine}");
}
def on_bar(self):
    lastBar = api.Bars.LastBar
    api.DataFile.AppendAllText(f"{lastBar.OpenTime},{lastBar.Close}\n")
{
  "Parameters": [
    {
      "Name": "DataFile",
      "DisplayName": "Data File",
      "Type": "File"
    }
  ]
}

AppendAllText(string contents, EncodingType encodingType)

Appends text to file that has a specified encoding.

void AppendAllText(string contents, EncodingType encodingType)
file.AppendAllText(contents: str, encodingType: EncodingType) -> None

Parameters

Name C# type Python type Description
contents string str The string to append to the file.
encodingType EncodingType EncodingType Encoding type

Examples

protected override void OnStart()
{
    DataFile.AppendAllText($"{Server.Time:O},{Symbol.Bid}{Environment.NewLine}", EncodingType.Utf8);
}
api.DataFile.AppendAllText(f"{api.Server.Time},{api.Symbol.Bid}\n", EncodingType.Utf8)
{
  "Parameters": [
    {
      "Name": "DataFile",
      "DisplayName": "Data File",
      "Type": "File"
    }
  ]
}