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"

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
    Also it was necessaire to change the type argument from for each from object to string

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