File.WriteAllText
method · File · cAlgo.API Since 5.7
DesktopCLICloud
Overwrites file content with passed text content.
Environment behaviour
Cloud — not supported. Exists returns false; reads return empty string/array; writes and appends silently do nothing. No exception.
Overloads
| Signature | Description |
|---|---|
WriteAllText(string contents) | Overwrites file content with passed text content. |
WriteAllText(string contents, EncodingType encodingType) | Overwrites file content with passed text content that has a specified encoding. |
WriteAllText(string contents)
Overwrites file content with passed text content.
void WriteAllText(string contents)
file.WriteAllText(contents: str) -> None
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
contents | string | str | The string to write to the file. |
Examples
protected override void OnStart()
{
DataFile.WriteAllText($"{SymbolName},{Symbol.Bid},{Symbol.Ask}");
}
api.DataFile.WriteAllText(f"{api.SymbolName},{api.Symbol.Bid},{api.Symbol.Ask}")
{
"Parameters": [
{
"Name": "DataFile",
"DisplayName": "Data File",
"Type": "File"
}
]
}
WriteAllText(string contents, EncodingType encodingType)
Overwrites file content with passed text content that has a specified encoding.
void WriteAllText(string contents, EncodingType encodingType)
file.WriteAllText(contents: str, encodingType: EncodingType) -> None
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
contents | string | str | The string to write to the file. |
encodingType | EncodingType | EncodingType | Encoding type |
Examples
protected override void OnStart()
{
DataFile.WriteAllText($"{SymbolName},{Symbol.Bid}", EncodingType.Utf8);
}
api.DataFile.WriteAllText(f"{api.SymbolName},{api.Symbol.Bid}", EncodingType.Utf8)
{
"Parameters": [
{
"Name": "DataFile",
"DisplayName": "Data File",
"Type": "File"
}
]
}