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

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:
dt

so we can check the datatable

then type in:

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