复制一个文件夹下的所有文件(复制文件、遍历目录)

来源:互联网 发布:法甲数据 编辑:程序博客网 时间:2024/04/28 06:30
BOOL CopyFilesFromTmptoLocal()
{
    CFileFind find;
    
    CString strFile = TMPPATH;
    strFile += _T("*.*");

    BOOL bFind = find.FindFile(strFile);

    while (bFind)
    {
        bFind = find.FindNextFile();

        CString strPath = find.GetFilePath();

        if (find.IsDots())
        {
            continue;
        }

        if (strPath.Find(_T("Config.ini"), 0) != -1)
        {
            CopyFile(strPath, CONFIGFILE, FALSE);
        }
        else
        {
            CString strName = find.GetFileName();

            CopyFile(strPath, PICTUREPATH + strName, FALSE);
        }
    }

    find.Close();

    return TRUE;
}