1、 CString CPrjGetFileExtendNameDlg::GetFileExtendNameBetter(CString strFileName) { int intCharPosition; //Find "//",Get The File's Name intCharPosition = strFileName.ReverseFind('//'); if(-1 != intCharPosition) { strFileName = strFileName.Right(strFileName.GetLength() - intCharPosition - 1); } //Find ".",Get the file's extend name intCharPosition = strFileName.ReverseFind('.'); if(-1 != intCharPosition) { strFileName = strFileName.Right(strFileName.GetLength() - intCharPosition - 1); return strFileName; } else { //No extend name return ""; } } 2、 CString CPrjGetFileExtendNameDlg::GetFileExtendName(CString strFileName) { int intCharPosition; //Find "//",Get The File's Name while(1) { intCharPosition = strFileName.Find("//"); if(-1 != intCharPosition) { strFileName = strFileName.Right(strFileName.GetLength() - intCharPosition - 1); } else { break; } } //Find ".",Get the file's extend name //No extend name if(-1 == strFileName.Find(".")) { return ""; } else { while(1) { intCharPosition = strFileName.Find("."); if(-1 != intCharPosition) { strFileName = strFileName.Right(strFileName.GetLength() - intCharPosition - 1); } else { break; } } return strFileName; } }