How to output text from collections?

Hi all,

I’m scraping text from website (page by page)
now I want to output data in txt file?
How should I do that?

I looped the data extraction process with “Do While” cycle and added all extracted text to collections
Now I’m trying to output information from collections, but “write txt” does not allow me do that.
Could you advise on outputting from collections?

Hi @Indiroy

You cannot directly write the entire collection to a text file. you will need to loop through your collection and get one element at a time and then write it to the text file.

So, there are two activities that can be used to write… The best suitable one would be Append Line item so that you will not overwrite the existing text in your text file. The input for this activity is just a string/ String variable.

Use a For Each loop to loop through the collection, within the loop, add an Append Line activity and write the selected item to the text file.

This should work for you… Let know if it doesn’t :slight_smile:

Hi @Indiroy,

You can write each item of your collection to a text file by using a for each loop like @Lahiru.Fernando explained. If your data is a list or an array, you can do it at once by using an “invoke method” activity with target type as “System.IO.File” and method name as “WriteAllLines”. Then pass the parameters, ‘filepath’ and your collection as string array.

Warm regards,


Hi @nimin

The invoke method to write all lines was something new for me as well… thanks for sharing :slight_smile:

By the way, do you know a location where i can find a full list of methods which we can invoke through invoke method? Since we have to type and specify the exact method name, knowing all the capable methods we can use would be great… if you could share that sort of info if you have, that would be great… Thanks again…



If you want to write the List(Of String) into a text file, then you can write using Append Line activity with since line of code, pass this parameter in the text parameter of the Append Line Activity.

You have to pass your string list here, this will write the entire string list into the text file line by line.

String.Join(Environment.NewLine, yourListStringInput)

Hi @Lahiru.Fernando,

These are .Net framework class functions of System.IO.File.

You can find the details in the below link.

Sasikumar K

1 Like

Hi @Sasi.lalo

Thanks a lot for sharing… it is really helpful for me… :slight_smile:

Thanks again!!