Error : "ERROR Validation Error Compiler error(s) encountered processing expression "new FileInfo(Invoicess)".(2) : error BC30451: 'Invoices' is not declared. It may be inaccessible due to its protection level. Main.xaml"

Hello everyone, I encountered an error while debugging the program. Despite following the steps shown by the video instructor in the RPA Developer Foundation course, the program is not running smoothly for me. I would be incredibly grateful if someone could assist me in resolving this issue!

can you check the typo / difference from loop variable Invoice vs. Invoicess

Thank you for replying. No, it is not the typo, because I intentionally changed it due to the similarity with another file name.

not fully clear, due we would need to know more details as in general the shown part do lead to some doubts. Can you share your xaml?

1 Like

SwitchSequence.zip (632.7 KB)
Please check it

The correct expression for “value to save” would be Path.GetFileInfo(file path and name)

The expression you’re using is to create a new variable of type FileInfo. The way to actually get file info is by calling the GetFileInfo method

But there is also a Get File Info activity.

1 Like

By the way, if you’re trying to get the filename, you don’t have to do it in multiple steps. You don’t even need to use variables and assigns.

Inside your loop, wherever you want to use the filename you just use the expression: Path.GetFileName(Invoice)

1 Like

lets try to summarize the aimed steps:

  • set a source directory - “All Invoices”
  • loop over all files found in the source directory
  • calculate the filename without filetype extension (2019,2020…)
  • move the loop the file to a subfolder of “All invoices” representing the year similar to the year from file name

given Implemenation

  • will need some corrections and also we would recommend some more optimal code changes

The validation issue

  • as mentioned above the loop variable and the used variable name are missmatching
  • when using the loop var name and changing the assign statement we do see
    grafik
    Also it was necessaire to change the type argument from for each from object to string
    grafik

In general we would recommend to get more familliar with

and then rework afterwards your implementation

For inspection and quick prototyping we can use the debugging panels as presented here

with this

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.