Is it possible to include embedded resources into .algo files?

Created at 06 Nov 2019, 11:05
FI

firemyst

Joined 26.03.2019

Is it possible to include embedded resources into .algo files?
06 Nov 2019, 11:05


HI everyone:

Is it possible to embed files, such as text files as an "embedded resource" into .algo files?

As a test, I've been trying to embed a json file, which is included in the project:

And then I've been trying all kinds of code tricks to try and read the file to no avail. Here's the latest rendition of code I've tried:

private const string CONST_jsonLicenseFile = "2020HybridLicences.json";
//... 
try
                {
                    var assembly = Assembly.GetExecutingAssembly();
                    string resourceName = assembly.GetManifestResourceNames().Single(str => str.EndsWith(CONST_jsonLicenseFile));

                    using (Stream stream = assembly.GetManifestResourceStream(resourceName))
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        theJson = reader.ReadToEnd();
                    }
                    //dynamic fileJsonDe = JsonConvert.DeserializeObject(theJson);
                }
                catch (Exception e)
                {
                    Print("WARNING! Could not read the license file.");
                    Stop();
                    return;
                }

Resource name always comes back as null.

I've also tried other suggestions such as from StackOverflow:

https://stackoverflow.com/questions/3314140/how-to-read-embedded-resource-text-file

to no avail.

So was just wondering if it's even possible or if cTrader cBots cater for this kind of scenario?

Thank you.


@firemyst
Replies

PanagiotisCharalampous
06 Nov 2019, 11:12

Hi FireMyst,

At the moment embedded files are not supported in cTrader Automate.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
07 Nov 2019, 10:02

Hi FireMyst,

Note that from v3.6 and onwards embedded resources via .resx files will be supported. So you will be able to use a resources file to embed your file and call it from a cBot. This post might be helpful.

Best Regards,

Panagiotis


@PanagiotisCharalampous