In another forum I posted a link to an FAQ: "Accessing a directory and all the files within it". Did you follow the link?
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
yes sir, i did that,...... but that doesnt work with VC++ :sad:
i tried those... plz help
Hmm. The last one I copied and pasted and compiled with no mods using VC6...--------------------Configuration: testpp - Win32 Debug--------------------
Compiling...
testpp.cpp
Linking...
testpp.exe - 0 error(s), 0 warning(s)Seems just fine to me.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
The following code is from the msdn library, slightly modified and tested with Dev-C++
// create a list of files in a given directory
// http://msdn.microsoft.com/library/en-us/fileio/fs/listing_the_files_in_a_directory.asp
// tested with Dev-C++
#define _WIN32_WINNT 0x0501
#include <windows.h>
#include <string.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind = INVALID_HANDLE_VALUE;
char DirSpec[MAX_PATH];
DWORD dwError;
argv[1] = "C:\\"; // for testing only
printf ("A list of files and subfolders in folder %s\n", argv[1]);
strncpy (DirSpec, argv[1], strlen(argv[1])+1);
strncat (DirSpec, "\\*", 3);
hFind = FindFirstFile(DirSpec, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
{
printf ("Invalid file handle. Error is %u\n", GetLastError());
return (-1);
}
else
{
printf ("%s\n", FindFileData.cFileName);
while (FindNextFile(hFind, &FindFileData) != 0)
{
printf ("%s\n", FindFileData.cFileName);
}
dwError = GetLastError();
FindClose(hFind);
if (dwError != ERROR_NO_MORE_FILES)
{
printf ("FindNextFile error. Error is %u\n", dwError);
return (-1);
}
}
getchar(); // wait
return (0);
}
You will have to work on this, separate the files from the subfolders and put them into an array or vector.
vegaseat
DaniWeb's Hypocrite
5,987 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417