int length = sPath.GetLength(); CString sFormat = _T(""); for (int i = length - 1; i > 0;i--) { if (_T('.')==sPath.GetAt(i)) { sFormat = sPath.Right(length - i - 1); break; } }