Hi All Good Morning. Can any one please tell me how to read multiple text files inside a folder at a time. thanks in Advance. Have a Nice Day.
Just like you would do one file you can read more than one file as well. I am not able to understand what you are trying.
Thanks Admin i am reading a directory and trying to store the file names in a hash table.. but i just want to now how to read a directory of files. i hope u will be clear now. Regards
For example here's some code from a project of mine, but this isn't going to be a lot of use to you if you're not using the Windows API: Code: void recurseDir(const char *dir,int recfunc) { WIN32_FIND_DATA FindFileData; HANDLE hFind; int bFin=0; char startDir[1024]; strcpy_s(startDir,1024,dir); strcat_s(startDir,1024,"\\*.*"); hFind=FindFirstFile(startDir,&FindFileData); while (!bFin) { if (hFind==INVALID_HANDLE_VALUE) bFin=1; else { if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { // skip . and .. if (strcmp(FindFileData.cFileName,".") && strcmp(FindFileData.cFileName,"..")) { char loc[1024]; strcpy_s(loc,1024,dir); strcat_s(loc,1024,"\\"); strcat_s(loc,1024,FindFileData.cFileName); if (recurseFuncData.skipSkipDirs && skipDir(FindFileData.cFileName,loc)) { //printf("Skip dir '%s'\n",loc); } else { //printf("Recurse into directory '%s'\n",loc); recurseFuncData.dirCount++; recurseDir(loc,recfunc); } } } else { //printf("Found file '%s'\n",FindFileData.cFileName); //recurseFuncData.fileCount++; strcpy_s(recurseFuncData.fromDir,1024,dir); if (!recurseFunc(recfunc,&FindFileData)) bFin=1; } } if (!FindNextFile(hFind,&FindFileData)) bFin=1; } FindClose(hFind); }