Hello everybody!
i have a problem with find file in a specific folder.
I have this Sequence: Variable1: “C:\test\testFilePdf” Variable2: directory.GetFiles( Variable1,“*.PDF”) Variable3: “5004317108”
For each item in Variable2
if item.contains(Variable3)
then else
The automation it’s ok but the PROBLEM is the completion time because inside the folder Variable1 there are 10.000 pdf
For each item the auomation need 2 minutes to find the files.
The entire workflow would need to be completed 3 days! ( i need to find 5.000 item)
There are another way to find my VARIABLE3 inside a folder?
@Loris_Sambinelli
give a try on:
Using an assign activity:
left side: Results (Array of String Datatype)
right side:
Variable2.Where(Function (x) x.Contains(Variable3)).toArray
it will return an array of strings with all items from Variable2 where Variable3 is contained in the filepath
I believe you search through all files for every search. Thats why it takes 2 minutes.
System.IO.Directory.GetFiles(Variable1, “*”.PDF) already skims through all files. No need to loop through anything.
I understand your idea ( i think you have wright) but i can’t understand your trycatch.
Wich of variable is Filexists ?
Can you explain please? thanks a lot
Using an assign activity:
left side: Results (Array of String Datatype)
right side:
Variable2.Where(Function (x) x.Contains(Variable3)).toArray
the LINQ statement checks each entry from variable if it contains the value of Variable3 in its item
All positive matches will be collected within an array
As mentioned above it will return an array of Strings ( String( ) )
However the solution approach from @TastyToast maybe with this variation directory.GetFiles( Variable1,"*" + Variable3 + "*.PDF")
could help to filter it directly. So give a try on this as well
Finally i found why i can’t do my automation!
If i use
Directory.Getfiles(Path,“*.PDF”).Where(Function (x) x. Contains( Variable3)).ToArray
and my Variable3 is: "“C:\test\testFilePdf\INV_10004_5004317108.PDF” the automation it’s done!
But my problem is in my Variable3. My variable it’s only 5004317108
the automation with only number invoice without path crash because the results it’s nothing.