Come ti ha scritto anche oregon puoi usare :

system("DIR c:\\Programmi > c:\\dir.txt");