title: Change file/path extension
body: <p>Using VC++, how can I remove the extension from the following file path and change it to a new extension(using strings):</p>
  
  <pre><code>CString path(_T(m_DirTree.GetCurrentDir()));             // copy file path to variable 'path' of type CString
  
  //Add code here....
  </code></pre>
  
  <p>The path to the file in question is L:\PowerStar 5 Demo II\Programs\Demo\Programs\33100.PRG and I would like to change the file extension to 33100.CRC. Is there some way I could use _splitpath to change the file extension to .CRC? This path is one of many which can be selected via a directory tree that is passed to variable path and I am just using this particular path as an example. So I cannot alter it as below: </p>
  
  <pre><code>CString path(_T("L:\PowerStar 5 Demo II\Programs\Demo\Programs\33100.CRC"));
  </code></pre>
  
  <p>Is it possible to concatenate the strings so I can open without getting an exception? </p>
  
  <pre><code>char drive[_MAX_DRIVE]; 
  char dir[_MAX_DIR]; 
  char fname[_MAX_FNAME]; 
  char ext[_MAX_EXT];
  
  
  // Split path to isolate file extension(.prg) for if statement 
  
  _splitpath(m_DirTree.GetCurrentDir(), drive, dir, fname, ext);
  
  CString crcFile; 
  
  crcFile = strcat(fname,".CRC");  // concatenate chars to point to .CRC file of same name
  
  
  FILE *cr = fopen(fname, "r");  // Handle to the file in question
  </code></pre>
  
  <p>The above code throws an unhandled exception.</p>