• Advertisement

Archived

This topic is now archived and is closed to further replies.

File Listing...

This topic is 5621 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do you list all the files in a directory using C/C++? OR How do you open the standard Windows Open Dialog Box?

Share this post


Link to post
Share on other sites
Advertisement
To get all the files in a Dir you use the FindFirstFile() and FindNextFile() functions, look them up on msdn, and to open the standard dialog you use the getopenfilename()\getsavefilename() functions... eg heres some source riped striaght out of my current project
  
OPENFILENAME ofn;
char szFile[300] = {''\0''};

ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = App.CWindows.hMain;;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "NewsAgent Project *.prj\0*.prj\0All *.*\0*.*\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = 0;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

if(!GetOpenFileName(&ofn)) break;

Share this post


Link to post
Share on other sites

  • Advertisement