I cannot see all the results when this finds all the files in the console window. So I made it write it to a file but it only writes a couple on the file path's. Why is it only printing a few?? ThanksCode:#define MAX_PATH 256; #include "stdafx.h" #include <windows.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <iostream.h> #include <fstream.h> void dir(char *path); int main() { dir("\\"); return 0; } void dir(char *path) { FILE *fp; char dirname[MAX_PATH]; HANDLE fhwnd; WIN32_FIND_DATA WFD; SetCurrentDirectory(path); fhwnd = FindFirstFile("*.*", &WFD); fp = fopen("C:/Matt/files2.doc","w"); while(FindNextFile(fhwnd,&WFD)) { if( (WFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (strcmp(WFD.cFileName, "..") && strcmp(WFD.cFileName, ".")) ) { GetCurrentDirectory(MAX_PATH,dirname); if(strncmp(&dirname[strlen(dirname) - 1], "\\", 1)){ strcat(dirname, "\\"); } strcat(dirname, WFD.cFileName); cout << dirname; fprintf(fp,dirname); fprintf(fp, "\n"); cout << endl; dir(dirname); } } FindClose(fhwnd); fclose(fp); }





Reply With Quote