   Question: Getting a file-name
  Hiya folks, I've got a little question for you knowledgable people!  I am working on a little archive, which will take a load of files based on a text template, and shove them into one file along with a way to get them out again.  However, I have one question, before I actually move from pseudo-code and conjecturing to actual C++.  Is the a Win32 API function to simply return the name of the first file in a folder?  Something like 'FindFirstFile', except that it doesn't take a parameter, it just gives me some way of getting the name, so I can open it up with 'ifstream'.  Oh, also, if this is possible, is there also a way to do this same thing, but return the name of a folder, instead of a file?  Thanks a lot!  Any and all help or pointers appreciated![EDIT] It seems that you can use '*' and '?' in FindFirstFile, so that should work for the files at least, but, um, I still need help on the folder bit.  Thanks![EDIT] Bah, brainfreezes, can't live with em, can't li....  No wait, cross that, leave it as 'can't live with em' [smile][Edited by - SirLuthor on January 20, 2005 9:35:30 AM]
  You were close ;-)MSDN: FindFirstFile();  Note that FindFirstFile/FindNextFile will also return the . (current) and .. (parent) directory's, you probably don't want to open these.   ;  Prototype: A bad double-typo by me, I knew what I was talking about, had the page open in fact, but put down 'GetFirstFile' anyway :/  Brainfreeze there, methinks.  Anyway, can you get a directory with that as well?twanvl: I'm going to be experimenting with it first naturally, so in the end, I'd probably have found out, but, either way, thanks for the tip!   ;  Yes you can also retrieve directories. Use the lpFindFileData structure (orGetFileAttributes() function) to determine what type of file it is. It was explained in the MSDN link too so you should read more carefully ;-)   ;  Actually when using FindFirstFile you'll get a struct that already carries the attributes of the file/directory.So no need to an extra call of GetFileAttributes.But as twanvl said, ignore the "." and ".." directories you'll get.   ;Quote:Original post by EndurionActually when using FindFirstFile you'll get a struct that already carries the attributes of the file/directory.Corrected that :)   ;  Thanks folks, I appreciate it!   