Any way to create text file of directory file list?

I have tried using:

WinExec("dir *.* /b/o-n > file.ext", SW_HIDE);

This does not work under NT, any suggestions?