Hello!!
This is really easy with a simple piece of code, just follow this steps:
In the Object Properties, add:
External References: System.IO.dll
Namespace Imports: System.IO
Create a new page, and add a "code stage"
Define the Inputs / outputs:
inputs: variable "Path" as a Text
outputs: variable "dtResult" as a Collection
Need to paste your path on the "Path" input variable.
The code looks like that:
DataTable dt = new DataTable();
dt.Columns.Add("fileName", typeof(String));
dt.Columns.Add("lastLine", typeof(String));
DataRow row;
String[] arLines;
foreach(String file in Directory.GetFiles(Path))
{
row = dt.NewRow();
arLines = File.ReadAllLines(file);
row[0] = file;
row[1] = arLines[arLines.Length-1];
dt.Rows.Add(row);
}
dtResult = dt;
You don't need to use a second loop to get the last line. Is better to use "File.ReadAllLines" and then get the last from the array list.
Hope this helps you
Bye
🙂------------------------------
Pablo Sarabia
Programmer
Altamira AM
------------------------------