Array to List

Hello Team,

I have array with few invoices and one of these invoices name stats with “Invoice” keyword.

I have to add the invoice whose name start with “Invoice” at 0th position of array or list and remaining invoices need to added to other position except oth position so that I can use that in further steps.

Any help?

@Shirish
find a small demo with some dummy values. Just replace A with e.g. Invoice

arrValues.Where(Function(x) x.StartsWith(“A”)).Concat(arrValues.Where(Function(x) Not x.StartsWith(“A”))).ToArray

In general Lists are to prefer for such tasks. In case of the element is not present and is to insert e.g. the InsertAt method from lists can be used within an invoke method activity.

hello @ppr,

it is not working.

filesPath is string of array

filesPath = Directory.GetFiles(“C:\Users\user\Desktop\PDFTOTIFF\New folder”,"*.pdf")

filesPath = filesPath.Where(Function(x) x.StartsWith(“Invoice”)).Concat(filesPath.Where(Function(x) Not x.StartsWith(“Invoice”))).ToArray

when I am printing this string array, it is not printing Invoice named PDF at 1st position but giving at last location. Can u please check what went wrong

@Shirish
filesPath = Directory.GetFiles(“C:\Users\user\Desktop\PDFTOTIFF\New folder”,"*.pdf")

  • retuns an array with the fullfile paths to files
  • the item representing the invoice is starting in the filename with invoice but not in entry of filesPath (The part of containing folder is for all the same)

for working on fileName base we can do:
arr1 = filesPath.Where(Function(x) Path.GetFileName(x).ToUpper.StartsWith(“INVOICE”)).toArray
arr2 = filesPath.Where(Function(x) Not Path.GetFileName(x).ToUpper.StartsWith(“INVOICE”)).toArray
FilesPathOrdered = arr1.Concat(arr2).ToArray

Find some starter help here:
BringInvoiceToFirst.xaml (6.0 KB)

Thank You @ppr

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