通过dlg.GetPathName()取得了文件名和路径,怎样得到只一个文件路径名?(不能使用dlg.GetFolderPath取得路径!!!!!!!!!!!!??????????????WHY????)         
我的具体做法是:做一个按钮,void CChecknumDlg::OnSaveAs() 
{
CFileDialog dlg(FALSE, 
"jak", 
NULL, 
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT,
"file (*.jak)|*.jak|all file(*.*)|*.*|",
this);
if(IDOK == dlg.DoModal ())
{
CString strfilename = dlg.GetFileName();//得到文件名
CString strpathandfilename = dlg.GetPathName();//得到文件名和路径

CFile myFile;
CFileFind myFindfile;
if(myFindfile.FindFile (strfilename) == FALSE)//没有找到文件名新建文件名
    {
myFile.Open (strfilename,CFile::modeCreate|CFile::modeWrite);
myFile.Write (strpathandfilename,strpathandfilename.GetLength ());//写入文件名和路径;

解决方案 »

  1.   

    if(IDOK == dlg.DoModal ())
    {
    CString strfilename = dlg.GetFileName();//得到文件名
    CString strpathandfilename = dlg.GetPathName();//得到文件名和路径

    CFile myFile;
    CFileFind myFindfile;
    if(myFindfile.FindFile (strfilename) == FALSE)//没有找到文件名新建文件名
        {
    myFile.Open (strfilename,CFile::modeCreate|CFile::modeWrite);
    myFile.Write (strpathandfilename,strpathandfilename.GetLength ());//
    生成一个全局变量~~解决~~
      

  2.   

    //接楼主的代码,再加上下面这句:
    CString strpath = dlg.GetPathName().Replace(dlg.GetFileName(),"\0");
      

  3.   

    sorry,一着急上面的写错了:
    CString strpath = strpathandfilename;
    strpath.Replace(strfilename,"\0");