Jump to content

Featured Replies

Posted
Is there anyway to get the names of all the files in a specified directory, in c++?

The only way i can think of real quick is bruteforcing through all filenames.

I know how to do it in assembly (.com file only, since it requires interrupts).

Or you can use FindFirstFile and FindNextFile somthing like:

 

WIN32_FIND_DATA find;
HANDLE result;

result = FindFirstFile("C:\\myfolder",&find);
while (FindNextFile(result, &find) !=0)
{    
cout<<find.cFileName;
}

 

You need to include windows.h

  • Author
Or you can use FindFirstFile and FindNextFile somthing like:

 

WIN32_FIND_DATA find;
HANDLE result;

result = FindFirstFile("C:\\myfolder",&find);
while (FindNextFile(result, &find) !=0)
{    
cout<<find.cFileName;
}

 

You need to include windows.h

 

Actually, this is more help, because the other one uses a non-standard library. Thanks!

Actually, this is more help, because the other one uses a non-standard library. Thanks!

 

You didn't mention which OS you were using. :P

  • Author
Well come on... I'm not a genius, as you well know. I'm using windows. I'm thinking of switching to Linux, but my brother, who has the CD-Burner refuses to burn me a copy of the debian distribution.
Guest
This topic is now closed to further replies.