Extracting common code for open and save dialogs (folder contents).