While using cmd.exe in this manner can be useful for a number of things, in this case I'd use an inline function instead, as the API methods for listing files are available, and can get that data more directly.
E.G. this should duplicate the parameters of your current "dir" command by default:
using System;
using System.IO;
public class VAInline
{
public void main()
{
string path = VA.GetText("~~targetPath");
if (!Directory.Exists(path))
{
VA.WriteToLog("'" + path + "' is not a valid directory");
return;
}
string filter = VA.GetText("~~targetFilter") ?? "*";
SearchOption includeSubDirectories = SearchOption.AllDirectories;
if (VA.GetBoolean("~~excludeSubDirectories") == true)
{
includeSubDirectories = SearchOption.TopDirectoryOnly;
}
string[] files = Directory.GetFiles(path, filter, includeSubDirectories);
VA.SetText("~~fileList", String.Join(Environment.NewLine, files));
}
}
Usage example:
Set text [~~targetPath] to 'C:\Some\Directory\Structure'
Inline C# Function: Create file list, wait until execution finishes
Write [Blue] '{TXT:~~fileList}' to log
It optionally allows you to specificy a filter by setting the "~~targetFilter" text variable, but will otherwise list all files (and files only, not directories).
Searching subdirectories can be disabled by setting the "~~excludeSubDirectories" Boolean variable to true.