I want to read all files in a particular folder using C programming. HOw to do this. Thanks.
Ex: I have some 5 files in folder named c:\temp.
I want to read all files one after another and want to write output file for each input file.
The output files has to be saved in another folder named c:\output
How to do this. Plz any one give me suggestion how to start
No standard functions to scan directories.
On Windows use FindFirstFile/FindNextFile API, for example:
const char dirName = "c:\\temp\\";
const char dirScan = "c:\\temp\\*.*";
char* pname = 0; /* File name buffer */
HANDLE h = FindFirstFile(dirScan,&info);
if (h == INVALID_HANDLE_VALUE)
/* print message?.. */
pname = (char*)malloc(MAX_PATH); /* (char*) for C++ only */
if ((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
continue; /* skip directories */
/* Now we have the next file name... */
/* Open, process then close the file ...*/
} while (FindNextFile(h,&info));
FindClose(h); /* Close dir scan */