多谢!

解决方案 »

  1.   

    CStdioFile m_File; 
             CFileException m_Except;
    CFileFind m_find1;
    CString m_findstr;
    m_findstr="文件路径";
    if(!m_find1.FindFile(m_findstr))
    {
       m_File.Open(findstr, CFile::modeCreate, &m_Except);
            m_File.Close();   
    }
      

  2.   

    CString lpszFile="c:\\temp.txt";//设置文件的路径
    CFileFind finder;
    if(!finder.FindFile(lpszFile))
    {
    CStdioFile file;
    if(!file.Open(lpszFile,CFile::modeCreate|CFile::modeWrite))
    {
    return;//创建失败返回    
    }
             ...//创建成功
             file.WriteString(...);
             file.Close();
    }
      

  3.   

    HANDLE hFile = CreateFile( "c:\\test.bmp",
                                   GENERIC_WRITE,
                                   FILE_SHARE_WRITE,
                                   NULL,
                                   CREATE_ALWAYS,
                                   FILE_ATTRIBUTE_NORMAL,
                                   NULL );CREATE_ALWAYS: Creates a new file. If the file exists, the function overwrites the file and clears the existing attributes.
      

  4.   

    BOOL bRtn = TRUE;
    CStdioFile fLogFile;
    CFileFind fFind;
    if ( !fFind.FindFile(sFilePath, 0) )
    {
    //create log file
    if ( !fLogFile.Open(sFilePath, CFile::modeCreate | CFile::modeWrite) )
    {
    //error
    CErrMsg errMsg;
    errMsg.GetWarningErr(LOG_FILE_WRITE_ERR, sFilePath);
    bRtn = FALSE;
    }
    ......