Due to the extra "$", i am getting the array length error

Hello Smart people

I am checking how many Inmetro files is the folder .
Actually there is only 1 file ,but i am getting 2. It works correctly Before!
When i debug, there is extra $ right in front of the file name .Plx, see the pic.
The logic works for checking other file`s names.

The amazing thing is when i delete the Inmetro file from the folder, the result must be 0.
But the result in the write line shows 1 of $filename.

ArrInmetrofile=Arr_FindINMETRO.AsEnumerable().Where(Function(a)a.ToString.Contains(“INMETRO Commercial Code Request Sheet”)).ToArray

You can check this article why you are having the extra file starting with $

A solution for this would be:

Get all files from the directory as you are already doing.
Then make a loop for each file and to find the file you are interested in: Check if it is not starting with $ and filename is correct

1 Like

@eimon

Maybe following will help:
ArrInmetrofile=Arr_FindINMETRO.AsEnumerable().Where(Function(a)a.ToString.Contains(“INMETRO Commercial Code Request Sheet”) And Not a.Contains("~$")).ToArray

a rewrite of the statetment to the LINQ Query syntax would look like

(From a in Arr_FindINMETRO
Where a.Contains("INMETRO Commercial Code Request Sheet") And Not a.Contains("~$")
Select a).ToArray
1 Like

Thank you so much ppr Peter

Thank you @dimibot

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