How to store files in the Collection

Hello Guys,

I have a Purchase Orders(pdf) in a folder. Previously, I used directory.get files and stored those in a array of strings variable but,I want to use collections here. Will it be possible to use collection if so could any one let me know how to store those files in a collection.

1 Like
  • Initialize collection.
  • For each item in ListFileNames
  • Use add to collection activity.
1 Like

@ushu

In Assign activity, use the following code

Collection<string> collection = new Collection<string>(theList);

Regards,
Karthik Byggari

Thanks vivek and karthik
But, before using collection variable we need to store the all files from the respective path into List. Could you please let me know how to store all the files at a time into the List

@ushu

  1. Get the list of files in a directory using the Assign Activity

[fileArray is Array of Strings]

Assign Activity: fileArray = Directory.GetFiles(“Your Directory Path”)

  1. Convert Array to List

fileList (List of Strings)

Assing Activity: fileList = Arrays.asList(fileArray)

Regards,
Karthik Byggari

Thank you Karthik
Will try on it

Karthik,

While I am trying to convert from Arrays to List using
fileList=Arrays.asList(fileArray)
it was showing an error that Arrays is not declared. Could you please suggest

You can do,
fileList = fileArray.ToList

1 Like

Thanks nadim. WIll try on it