CFile有个rename,应该可以用。

解决方案 »

  1.   

    CString strFile("c:\\abcaaaaaaaaaaaaaaabc.txt");
    CString strExt(".PDF");
    CString strFile2;
    strFile2=strFile.Left(strFile.ReverseFind('.'))+strExt;
      

  2.   

    PathRenameExtension是专门做这个事情的
      

  3.   

    如何取得文件的路径:
    例如:
    file=“c:\\file\\file1.txt";
    如何取得“c:\\file\\”
      

  4.   

    msdn原文送上#include <windows.h>
    #include <iostream.h>
    #include "Shlwapi.h"void main( void )
    {    // Path to include file spec.
    char buffer_1[ ] = "C:\\TEST\\sample.txt"; 
    char *lpStr1;
    lpStr1 = buffer_1;    // Print the path with the file spec.
    cout << "The path with file spec is          : " << lpStr1 << endl;
     
        // Call to "PathRemoveFileSpec".
    PathRemoveFileSpec(lpStr1);// Print the path without the file spec.
    cout << "\nThe path without file spec is       : " << lpStr1 << endl;}
    OUTPUT:
    ==================
    The path with file spec is          : C:\TEST\sample.txtThe path without file spec is       : C:\TEST
      

  5.   

    如何取得文件的路径: 
    例如: 
    file=“c:\\file\\file1.txt "; 
    如何取得“c:\\file\\”
    ----------------------------CString file = "c:\\file\\file.txt";
    file = file.Left(file.ReverseFind('\\'));