Output a directory list to a text file
dir > test.txt

Output a directory list and subdirectories to a text file
dir > /s test.txt

Append to an existing file
dir >> test.txt