Security error when trying to log to a text file

Created at 29 Jan 2022, 07:26
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
CT

ctid3176453

Joined 03.02.2021

Security error when trying to log to a text file
29 Jan 2022, 07:26


Hi I'm trying to log some data to text file, with the line of C# code.

File.AppendAllText("C:\\Log\\TestSMB01\\Log.txt", "Hello World" + Environment.NewLine);

The file exists, and it works fine, in a normal C# app, but not in cTrader Automate. 

I'm getting the following error..

System.Security.SecurityException: 'Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.'

Can anyone help me sort it out...  thanks in advance.

ps.  I'm new to cTrader Automate, and just learning how to do it.


@ctid3176453
Replies

firemyst
30 Jan 2022, 13:24

You need to grant your cBot access.

Alter the line you have for [Robot ... ] to include the following:

[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]

 

 


@firemyst