vc中打开,查找(如vb中的dir),copy,之类的用法

解决方案 »

  1.   

    //查找文件
    CString filename;
    CFileFind finder;
    if(finder.FindFile(filename))
    {
        finder.FindNextFile();
        //Get It;
    }
    else
    {
        AfxMessageBox("file not found");
    }//拷贝文件
    BOOL CopyFile(
      LPCTSTR lpExistingFileName, // name of an existing file
      LPCTSTR lpNewFileName,      // name of new file
      BOOL bFailIfExists          // operation if file exists
    );
    Parameters
    lpExistingFileName 
    [in] Pointer to a null-terminated string that specifies the name of an existing file.lpNewFileName 
    [in] Pointer to a null-terminated string that specifies the name of the new file. bFailIfExists 
    [in] Specifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds. Return ValuesIf the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError.