Advertisement

how to get folders

Started by May 28, 2000 07:38 PM
6 comments, last by Mayasuke++ 24 years, 7 months ago
Nice to meet you. Please tell me how to get folder names inside of the current folder by SDK or so. I use VC++6.0.
Hello, nice to meet you too

Im not sure if I understood completely your question, but a way to find out which directory is the file being run is using the ... uhm, I dont know its name, so lemme show an example :

int main (int number_args, char **args){printf ("%s", args[0]);return (1);} 


Im not sure if Im doing right (long time I dont use this), but args[0] = "c:\whatever\filename.exe"

so you could find out the directory the file is in by doing some edit on that string.

Hope that helps, cya,
-RoTTer
Advertisement
Im sorry.
I am a Japanese student.
So I couldn''t use English completely.

I am making a DirectX Game.
I have to get some filenames.

So I want to get all filenames in one folder.

For example,
if one directory is
.
..
\pic
\sound
game.exe
readme.txt

then I want to get these filenames.

Please tell me.

If you use the Win32 API, you can use FindFirstFile, FindNextFile and FindClose to do the thing you want.

FindFirstFile takes a null terminated string that specifies a valid directory or path and file name, which can contain wildcards (? and *), and a pointer to the WIN32_FIND_DATA structure that receives info about the found file or subdirectories. The function returns a HANDLE that can be used in subsequent calls of FindNextFile or FindClose. The function will return INVALID_HANDLE_VALUE if it fails.

FindNextFile, which takes a handle returned by FindFirstFile and a pointer to the WIN32_FIND_DATA structure, returns a BOOL to indicate if the function failed or not. The function continues a file search from a previous call to FindFirstFile.

FindClose takes the handle and closes it.

Detailed info on the functions, associated structures and usage can be found in the Platform SDK docs, at http://msdn.microsoft.com/library/psdk/winbase/filesio_3h6b.htm

Erik
Ummm, I actually think that we are assuming that we know where the files are and what they are called, for instance I *know* there is a file called \gfx\player.bmp but how do I open it?

the standard fopen command doesn''t seem to accept this, but maybe I''m just doing something wrong.
Hey Mayasuke++,
Do u have ICQ?
I wanna have a chat with ya
i wanna know what type of game r u making now
please tell me
if u don''t want the public know your ICQ UIN
just mail me at : kenshin@winning.com
Thanks..
Advertisement
Thank you very much.
wise_Guy, yes you are..
"\gfx\player.bmp" is telling it to look on the root of the current drive in the directory gfx
try:
"gfx\player.bmp"

This topic is closed to new replies.

Advertisement