Environment Variables in MC .Net  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
TrTrading
Posts: 6
Joined: 17 May 2019
Been thanked: 1 time

Environment Variables in MC .Net

Postby TrTrading » 13 Jun 2019

I am trying to use the environment methods in C# .net in MultiCharts to get the location of the %appdata% folder on the computer.

Both the following code create errors in the MultiChart .Net Function that I am using:

Code: Select all

env_string = Environment.SpecialFolder.ApplicationData;

Code: Select all

env_string = Environment.ExpandEnvironmentVariables("%appdata%");
I get these errors:
'PowerLanguage.IApplicationInfo' does not contain a definition for 'SpecialFolder' and no extension method 'SpecialFolder' accepting a first argument of type 'PowerLanguage.IApplicationInfo' could be found (are you missing a using directive or an assembly reference?) "Test" [Function] Ln 136
'PowerLanguage.IApplicationInfo' does not contain a definition for 'ExpandEnvironmentVariables' and no extension method 'ExpandEnvironmentVariables' accepting a first argument of type 'PowerLanguage.IApplicationInfo' could be found (are you missing a using directive or an assembly reference?) "Test" [Function] Ln 136
Why do I get this error that there is no ExpandEnvironmentVariables?

The Environment class should be available when "using System;" which I already declared at the beginning of my code as described here:
And the intellisense in the PowerEditor shows these Environment methods.

Thank you.

TrTrading
Posts: 6
Joined: 17 May 2019
Been thanked: 1 time

Re: Environment Variables in MC .Net  [SOLVED]

Postby TrTrading » 13 Jun 2019

I think I found the problem. I should be using:

Code: Select all

env_string = System.Environment.SpecialFolder.ApplicationData;
I am not sure why it doesn't work with just "using System;" declared.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Environment Variables in MC .Net

Postby Henry MultiСharts » 13 Jun 2019

Hello TrTrading,

Environment Property is availalbe both in the system and MultiCharts .NET library, but in a different namespace. That is why you need to specify the full path to the required property.


Return to “MultiCharts .NET”