最近在做一个标密文件的管理软件,主要就是搜索整个电脑中的doc文档,然后搜索其中的关键字,就跟组卷系统类似,搜索标有“秘密”“绝密”“机密”这样的字眼。然后记录文件的路径。是使用vc实现的。

解决方案 »

  1.   

    FindFirstFile和FindNextFile结合在一起就行了。
      

  2.   

    查找文件夹中含关键字的文件。
    void TestCase::FindMyFile( CString& Path, bool& result, char *ptname[], int namenum )
    {
    CFileFind UnFile;
    CString   FileName;
    BOOL res = UnFile.FindFile(Path);
    if( res )
    {
    while( res&&!result )
    {
    res = UnFile.FindNextFile();
    FileName = UnFile.GetFileName(); if (UnFile.IsDots())
    continue;
    if( UnFile.IsDirectory() )
    {
    Path = UnFile.GetFilePath();
    Path += "\\*.*";
    FindMyFile(Path, result, ptname, namenum);
    }
    for( int i=0, count = 0; i<namenum; ++i )
    {
    if( FileName.Find(ptname[i])!=-1 )
    {
    ++count;
    }
    if( count==namenum )
    {
    Path = UnFile.GetFilePath();
    result = true;
    }
    }
    }
    }

    }
      

  3.   

    CFileFind类查找,找到以后比较比较关键字即可
      

  4.   


    人家要是用rar压缩或者把doc改后缀名了呢?