Sometimes our app needs to save some files, and to provide an interface for users to select, which is usually implemented with the CFiledialog class, but use this class to fill in a file name before saving, however, some We already know the file name, just need a user to specify a path to save, then we can open a path selection dialog for the user to select the path, as shown below, the user clicks the browsing button, popping up a dialog box, Let the user select the save directory of the file. This is not difficult, as long as the code can be implemented, the code is as follows: void cpage2 :: OnbtnBrowse () {lpmalloc pmalloc; browseinfo bi; if (succeeded (SucceEded)) // malloc memory for the lpmalloc struct {ZeroMemory (& bi, sizeof (bi)); // init to zero char pszDirName [MAX_PATH]; // the dir name will be saved here LPITEMIDLIST pidl; bi.hwndOwner = GetSafeHwnd (); bi.pidlRoot = NULL; bi .pszDisplayName = pszDirName; bi.lpszTitle = _T ( "select the directory to save the file"); bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_EDITBOX; bi.lpfn = NULL; bi.lParam = 0; if ((pidl = :: ShbrowseForfolder (& BI))! = Null) // Open the dialog {if (: shgetpathfromidlist (pidl, pszdirName)) // get the path {m_path = pszDirName; // Save the user specified by the user, later file Updatedata (false) is saved to the directory specified by m_path;} pmalloc-> free (PIDL); // free memory} PMalloc-> release (); // free memory}}