So, for the “Switch” activity Tutorial in the “Control Flow in Studio” course, I was told to use the following within an Assign activity, FileName is the Variable, and File.Name.Substring(0, File.Name.LastIndexOf("."c)) is the argument meant to retrieve the “Short file name” - as in the file name without the file type extension at the end (eg: .pdf, or .xlsx)
Name looks as if it should be a built in kind of thing - because the tutorial doesn’t claim it as a variable at all.
Thank you for any help you can provide
(I will add the solution file here as well, so that you know what they’re attempting to teach me) Switch Solution.zip (1.2 MB)
Ah… I think this name property thing should fix it.
Thank you - I feel stupid now - but I am a beginner after all.
Update:
hmmm - still says “Name” is not a member of “File” with that same error code.
I will try your alternative method
Same error even with your alternative method.
Well - thank you anyway - I will learn from this even if I can’t pull it off myself (I will look at the differences btwn my version and the solution’s version to see what differences might be causing the issue).
One more thing - open the expression in advanced editor and try hover over the “file” variable, it should show you the pop-up description of the variable like in screenshot below
The only reasonable explanation here, is that u declared ur File variable with the wrong type.
So your File variable doesnt reference a proper File object.
Look it up in ur variables panel. I bet thats the reson u got that error.
The only reasonable explanation here, is that u declared ur File variable with the wrong type.
So your File variable doesnt reference a proper File object.
Look it up in ur variables panel. I bet thats the reson u got that error.
No it doesnt … Variable names are handled seperatly from class names.
As long as you dont try to name your variable “if”, “else”, “true” or “false” or some other reserved keyword u are fine.
You are correct… lets see if that fixes it.
I have another funny bug that sais “Substring is not a member of FileInfo”
Which makes me think the system is contradicting itself.(Which clearly is not the case).
Update: Making it a string type did not fix the File Name retrieving activity.
It still says “Name is not a member of File”.
At least the “Substring is not a member of FileInfo” bug went away though.
Thank you for your help - please stop if this is wasting your time. I have an alternative method that has already proven to work (you’d be in shock if you saw what my alternative method was though )
is no bug:
Substring is a method from the String class
FileInfo is not a String
FileInfo.Name will return a String, therefore the Substring method can be used for the returned Name
I can recommend only thing: The provided sample “Switch Solution.zip” is correct. So study this example, compare with your workflow, find the difference.
And because working with UiPath you can’t avoid some .NET coding you should understand some .NET basics - what are data types, methods, propperties etc. For this you could also use “InteliSense” that is suggesting valid options in current context
It is showing File as a String which is wrong… but I wouldn’t know how to fix it since this isn’t a variable, and an assign activity doesn’t have an argument type property like the Switch activity does.
No. Because you did not declare variable with name “File” (like it is in the example) but with name “File_Var” it is interpreting “File” as .NET “File Class” as mentioned by @ptrobot before.