mfc 读取文件内容

void ReadFile(CString filePath)
{
    CStdioFile readFile;
    CString readLine;            // 读到的每一行
    BOOL flag = readFile.Open(filePath, CFile::modeRead);
    if (flag == FALSE)
    {
        MessageBox(_T("打开文件失败"));
        return;
    }
    else
    {
        while (readFile.ReadString(readLine)) 
         {
               TRACE("%s\n", readLine);
         }
    }
    return;
}

你可能感兴趣的:(mfc 读取文件内容)