CSPString AfxGetFileDirectory( CSPString strPathName, CSPString strDefault ) { if( strPathName.IsEmpty() ) return strDefault; CSPString strResult = strPathName; if( strResult.GetLength() > 0 ) { int nIndex = strResult.ReverseFind( '\\' ); if( -1 == nIndex ) nIndex = strResult.ReverseFind( '/' ); if( -1 == nIndex ) strResult = strDefault; else strResult = strResult.Left( nIndex ); } if( strResult.GetLength() <= 0 ) return strDefault; int nLen = strResult.GetLength(); if( nLen > 0 && strResult[nLen-1] != '\\' && strResult[nLen-1] != '/' ) strResult += STRING_DIRSEP; return strResult; }