separate_file_name_ext

 

Description

Check to see if the given file name has file extension name. if so, separate and get them.

Syntax

bool separate_file_name_ext( LPCSTR lpcszFilename, string * pstrFileName = NULL, string * pstrExt = NULL )

Parameters

lpcszFilename
[input] full path file name
pstrFileName
[output] if not NULL ,is used to receive the full path file name portion with file extention removed
pstrExt
[output] if not NULL ,is used to receive the file extention name, or "" if not found

Return

true if lpcszFilename contains a file extension name, false if not found

Examples

EX1

void separate_file_name_ext_ex1()
{
    string strFile = GetAppPath() + "separate_file_name_ext()_test.txt";
    string pstrFileName;
    string pstrExt;
    
    separate_file_name_ext(strFile, pstrFileName, pstrExt);
    
    //pstrFileName should be current work folder 's path + separate_file_name_ext()_test
    //pstrExt should be txt
    printf("pstrFileName is %s\npstrExt is %s\n", pstrFileName, pstrExt);
}

Remark

See Also

header to Include

origin.h

Reference