1. Method 1
TCHAR Pbuf[max_path]; // Variables for storing paths GetCurrentDirectory (MAX_PATH, pBuf); // gets the current directory of the program _tcscat_s (PBuf, _t ("\ \")); _tcscat_s (PBuf, AfxGetApp (),m_pszexename); _tcscat_s (PBuf, _t (".exe")); // get the full file name of the program
2. Method 2
CString Returnpath () { CString spath; 1 ), MAX_PATH); Spath.releasebuffer (); int NPos; = Spath.reversefind (_t ('\ \')) ; = Spath.left (nPos); return spath;}
----------------------------------------------------------------------------------------
CFileDialog Filedlg (TRUE, NULL, NULL, OFN_HIDEREADONLY | Ofn_overwriteprompt, _t ("All Files (*. *) |*.*| | " )); if (Filedlg.domodal () = = IDOK) {=//Get file path setdlgitemtext (EDIT2, m_strpath2) ; = Filedlg.getfilename (); //Get file name }
"Go" VC gets the path of the current program file, file name and path + file name