Monday, July 22, 2013

Return the filename from the full file path in MFC

Below is the code snippet for a C++ function to return the filename from the full file path in MFC:

#include "StdAfx.h"

CString CAppUtilManager::ExtractName(CString strFullPath) const
{
 int pos=strFullPath.ReverseFind('\\');
 return strFullPath.Right(strFullPath.GetLength()-pos-1);
}

No comments:

Post a Comment