Write Text File: Value cannot be null. Parameter name: source

String.Join(Environment.NewLine, dt.AsEnumerable().select(function() ((“SAP Code”).toString)).ToList)

for a flatten string we would do like below:

String.Join(Environment.NewLine, dt.AsEnumerable().select(function(x) x("SAP Code").toString).ToList)

i did it this way but i’m still getting the e

had verified the code against a sample datatable and was working

can you please check following

  • set a breakpoint on the write text file
  • debug and get paused
  • write within the immediate panel following statements:

so we can check the datatable

then type in:

String.Join(Environment.NewLine, dt.AsEnumerable().select(function(x) x("SAP Code").toString).ToList)

It’s not finding any data so the file it tries to write is empty, which causes the error.

Hi @pauloengenharia5 ,

Could you check if dt contains any values in the Locals/Immediate Panel?
Either you have read the table into another variable, or the workbook doesn’t contain any data.

Kind Regards,
Ashwin A.K

Hello @pauloengenharia5

Hope “dt” is your datatable variable?

You need to check whether the datatable is having some value and it has the header “SAP Code”.


Hi @pauloengenharia5

Check that your parameter are assigned correctly. (Don’t pass the Null value)

Can you provide us an sample input?


this is my workflow

Test.xaml (24.5 KB)

Your expression is returning no data, so the Write Text File activity faults with error “value cannot be null”

Share the sample input not the XAML file. @pauloengenharia5

As it clearly says, your expression is null. It doesn’t return any data. Write Text File can’t write an empty file.