Flee icon indicating copy to clipboard operation
Flee copied to clipboard

Why doesn't Path.GetFileName() work but GetFileName() works ?

Open varadhbhatnagar opened this issue 6 years ago • 3 comments

I have a string which says "Path.GetFileName(<path>) . This throws an exception , whereas when I use "GetFileName(<path>)" it works. Any idea why ? Am I missing something ?

varadhbhatnagar avatar Jul 21 '18 08:07 varadhbhatnagar

You have to provide more information.

eskaufel avatar Jul 21 '18 22:07 eskaufel

Hi @eskaufel . I have a string which says "#DECLARE script string = Path.GetFileName(<pathOfFile>)" . I have created a dictionary in which I want to keep the value of script after solving the RHS.

I am doing this

string value = "Path.GetFileName(<pathOfFile>)"
IDynamicExpression exp = context.CompileDynamic(value);
dValue = exp.Evaluate();

This throws an exception that Path is not an object .

It works if I change the script to "#DECLARE script string = GetFileName(<pathOfFile>)" .

How can I make it work with Path.GetFileName ?

varadhbhatnagar avatar Jul 22 '18 07:07 varadhbhatnagar

Flee expressions don't support namespaces. A name followed by a dot would need to be an object.

hunkydoryrepair avatar Jun 01 '21 18:06 hunkydoryrepair