I\'m making an application with wxWidgets that has a listbox in it. I want to get the current working directory of the application, and in that listbox, list all the folders
For listing all the folder names in a list,
#include "wx/dirdlg.h"
wxDirDialog dialog(parent, wxT("Testing directory picker"), cwd, wxDD_NEW_DIR_BUTTON);
if (dialog.ShowModal() == wxID_OK)
{
wxString path = dialog.GetPath();
wxMessageBox(path);
}
Note : You can use path
in any way you wish, here it just displays in a message box.
But of course if you want to display folder names in your custom dialog to your user, you can use RyanWilcox solution.
EDIT: In your code you have not created dirList
(or you have posted incomplete code)
wxArrayString MainWindow::createFolderList()
{
wxDir dir(wxGetCwd());
if ( !dir.IsOpened() )
;//handle this error here
wxString dirName = dir.GetName();
wxArrayString dirList;
dir.GetAllFiles(dirName, &dirList, wxEmptyString, wxDIR_DIRS | wxDIR_FILES);
//Note that next statement is optional
dirList.shrink();
return dirList;
}
Your implementation might differ, but I have adapted this code, from my own working code.