Meola_Attack
2010-09-10 13:01:57 UTC
void ExplorePC(char * directory, FILE * file)
{
WIN32_FIND_DATA data;
HANDLE hFind;
char slash[]="\\\\"; // directory + slash + point = directory\\*.*
char point[]="*.*";
char string[]="\\\\*.*";
strcat(directory,string);
hFind = FindFirstFile(directory,&data);
if(hFind == INVALID_HANDLE_VALUE)
{
if(strstr(string,directory)==0)
{
int characters = strlen(directory)-strlen(string);
directory[characters]='\0';
}
fprintf(file,"Impossible to explore the directory \"%s\".",directory);
return;
}
else
{
if(strstr(string,directory)==0)
{
int characters = strlen(directory)-strlen(string);
directory[characters]='\0';
}
fprintf(file,"The files that have been found in \"%s\" are:\n",directory);
strcat(directory,slash);// Remove \\\\*.* from directory to printf the original directory in the file. Then add slash to directory that is ready to be pasted to the new files.
while(FindNextFile(hFind,&data)!=0)
{
char buffer[MAX_PATH];
strcpy(buffer,data.cFileName);
if(GetFileAttributes(data.cFileName) & FILE_ATTRIBUTE_DIRECTORY)
{
if(strstr("FOUND.",buffer)!=0)
{
fprintf(file,"%s\n",buffer);
strcat(directory,buffer);
cout<
ExplorePC(directory,file);
}
}
}
}
return;
}
Ten points...Sorry for my bed English, I'm Italian