Код:

#include "stdafx.h"
#include <iostream.h>
#include <windows.h>
#include <conio.h>
#include <fstream>
using namespace std;
int _tmain()
{
fstream f("C:\\1.txt", std::ios::out);
if(!f)
{
cout << "Error";
return -1;
}
WIN32_FIND_DATA file;
HANDLE hfile;
char szpath[MAX_PATH];
cin.get(szpath,260,'\n');
lstrcat(szpath,"\\*.*");
hfile=FindFirstFile(szpath,&file);
if(hfile!=INVALID_HANDLE_VALUE)
{
do
{
cout<<file.cFileName<<endl;
f << file.cFileName;
Sleep(1000);
}
while(FindNextFile(hfile,&file)!=0);
FindClose(hfile);
}
getch();
return 0;
}