如何在mfc中打開文件並獲取文件名?
這符合妳的要求。s返回文件路徑# definedlg _ filter "所有文件(*。*)| * | " # defined LG _ ext " * " cfiledialog DLG(true,_ t (DLG _ ext),null,ofn _ hidereadonly | ofn _ overwrite prompt | ofn。如果(dlg。DoModal()= = IDOK){ position pos = DLG。GetStartPosition();while(pos!= 0){ cs strings = DLG。get next pathname(pos);}}下面這段代碼,可以選擇壹個文件夾,會返回文件夾的路徑。妳需要找到每個文件char * getpath (hwnd hwnd,char * p buffer){ browse info BF;LPITEMIDLISTlpitemmemset(& amp;bf,0,sizeofBROWSEINFO);bf.hwndOwner = hWndBf.lpszTitle= "選擇路徑";BF . ul flags = BIF _ RETURNONLYFSDIRS;//可以選擇LP item = shbrowseforgolder(&;BF);If(lpitem==NULL)//如果沒有選擇路徑,則返回0;//如果選擇了路徑,復制路徑並返回路徑長度shgetpathfromidlist (lpitem,pbuffer);returnpBuffer}