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 names (not full paths) in the cwd that contain a specific file.
I’ve already figured out how to get the cwd and return it as a wxString (not that I’m particularly sure it’s working, but I’ll find out soon enough) but I’m not sure how to get the list of folders and pass it to the listbox.
I’m brand new to wxWidgets, and relatively new to C++ and OOP. If you could find a good way to explain to me how to do this, it would be much appreciated.
Update: Went with using GetAllFiles, but now I get exceptions when I run it. Here is the offending code.
wxArrayString MainWindow::createFolderList()
{
wxDir dir = wxGetCwd();
dirAddress = dir.GetName();
dir.GetAllFiles(dirAddress, dirList, wxEmptyString, wxDIR_DIRS | wxDIR_FILES);
return *dirList;
}
You could use wxDirTraverser – you implement a subclass and override some methods which will be called depending if the item is a file or directory.
You could also use wxDir::GetAllFiles, which will return a wxArray (which might be more convient for you, displaying it in a list).