谢谢

解决方案 »

  1.   

    用找到所有的.JPG文件,然后删除就行了
    virtual BOOL FindFile(
       LPCTSTR pstrName = NULL,
       DWORD dwUnused = 0 
    );
    Parameters
    pstrName 
    A pointer to a string containing the name of the file to find. If you pass NULL for pstrName, FindFile does a wildcard (*.*) search. 
    dwUnused 
    Reserved to make FindFile polymorphic with derived classes. Must be 0. 
    Return Value
    Nonzero if successful; otherwise 0. To get extended error information, call the Win32 function GetLastError.BOOL DeleteFile(
    LPCTSTR lpFileName ); 
    Parameters lpFileName 
    [in] Pointer to a null-terminated string that specifies the file or database volume to be deleted. 
    Return ValuesNonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError
      

  2.   

    用这种方法,必须知道文件的全名,可我并不知道文件的名字,只想删掉所有以.jpg结尾的文件,谁有办法?
      

  3.   

    递归FindFile("文件夹\*.jpg",0)
    FindNextFile()对文件夹递归
      

  4.   

    haha 
    记得还有所有的 *.avi/*.rm/*.mpg/*.dat
    都要删掉哦~~~~~~~~~~~
    :))))))))))
      

  5.   

    CFindFile可以查找文件,删除应该没问题
      

  6.   

    CFileFind finder;
       CString strWildcard(pstr);
       strWildcard += _T("\\*.jpg");   BOOL bWorking = finder.FindFile(strWildcard);   while (bWorking)
       {
          bWorking = finder.FindNextFile();      
          if (finder.IsDots())
             continue;     
          if (finder.IsDirectory())
          {
             continue;
          }
         DeleteFile(finder.GetFilePath());
       }   finder.Close();
      

  7.   

    这段代码是删除一个文件夹里所有文件和文件夹本身的。自己看看吧。你可以判断filestruct.name,不过似乎麻烦了些。
    _chdir(Dir);
    handle = _findfirst("*", &filestruct);
    if(handle == -1)
    //  ("文件夹为空!")
    {
    _rmdir(Dir);
    }
    else//删除所有文件
    {
    do
    {
    CString FileName;
    FileName.Format("%s",filestruct.name);
    if(FileName=="."||FileName=="..")//如果为当前目录或是父目录,继续
    continue;
    TRY
    {
    CFile::Remove(FileName);
    }
    CATCH( CFileException, e )
    {
    #ifdef _DEBUG
    afxDump << "File " << FileName << " cannot be removed\n";
    #endif
    }
    END_CATCH

    }
    while(!(_findnext(handle,&filestruct))); 
    _findclose(handle);
    _chdir("..");
    _rmdir(Dir);
    }