Thread: Folder listing

  1. #1
    ResurgentBarbecue UnclePunker's Avatar
    Join Date
    May 2002

    Folder listing

    Hi using MFC how could I go about getting the listing of folder on a certain drive, say I get the user to choose the drive from a drop down box, how can i then look at that drives contents, but specifically folders.

    Compiler == Visual C++ 6.0
    "Come Out Fighting."

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    ResurgentBarbecue UnclePunker's Avatar
    Join Date
    May 2002
    Thanks, that will probably help, it's gonna take me a while to understand it properly though.
    Compiler == Visual C++ 6.0
    "Come Out Fighting."

  4. #4
    Join Date
    Jan 2002
    Another possibility is to use a CListBox control and fill it up with file/directory names with the DlgDirList api. Something like:
    //get length of path to windows dir
    int len=GetEnvironmentVariable("windir",0,0);
    if (len)
      char *path=new char[len+1];
      //fill listbox with file/directory names
      int ret=::DlgDirList(*this,path,IDC_LIST1, IDC_STATIC_DIR,
      delete[] path;
    where this is the CWnd parent object of the CListBox control, IDC_LIST1 is the listbox id and IDC_STATIC_DIR the id of a 'buddy' static control. You might have to fiddle around a bit to get a format to suit (eg. convert short to long filenames).

    I don't use mfc much so there may be a more mfc friendly way of implementing this approach that others may be able to suggest.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading .dat files from a folder in current directory...
    By porsche911nfs in forum C++ Programming
    Replies: 7
    Last Post: 04-04-2009, 09:52 PM
  2. accessing all files in a folder.
    By pastitprogram in forum C++ Programming
    Replies: 15
    Last Post: 04-30-2008, 10:56 AM
  3. Not able to access directory of home folder
    By Bargi in forum Linux Programming
    Replies: 1
    Last Post: 02-06-2008, 02:45 AM
  4. read only folder on Windows
    By George2 in forum Windows Programming
    Replies: 2
    Last Post: 11-05-2007, 09:18 AM
  5. Hiding a folder
    By nextstep in forum Windows Programming
    Replies: 16
    Last Post: 03-20-2005, 03:07 PM