Find file with wildcards on entire disk
<p>I need to find a variable extension file using wildcards (<code>*.txt</code>, <code>*.jpeg</code>, <code>*.doc</code>) on a disk (<code>c:</code>).</p>

<p>I tried with the following function, but I can't make it recursive, and it's not working:</p>

<pre><code>void Recurse(LPCTSTR str)
{
    WIN32_FIND_DATA file;
    cout &lt;&lt; "Value INPUT:" &lt;&lt; str &lt;&lt;"\n";
    HANDLE search_handle=FindFirstFile(str,&amp;file);
    if (search_handle) {
        do {
        if(file.dwFileAttributes &amp; FILE_ATTRIBUTE_DIRECTORY &amp;&amp;
                strcmp(file.cFileName,"..")!=0
                &amp;&amp; strcmp(file.cFileName,".")!=0
                &amp;&amp; strcmp(file.cFileName,"$Recycle.Bin")!=0
                &amp;&amp; strcmp(file.cFileName,"Recovery")!=0
                &amp;&amp; strcmp(file.cFileName,"System Volume Information")!=0
                &amp;&amp; strcmp(file.cFileName,"PerfLogs")!=0
                &amp;&amp; strcmp(file.cFileName,"Windows")!=0)
            {
                str = file.cFileName;
                cout &lt;&lt; "Directory :" &lt;&lt; file.cFileName &lt;&lt;"\n";
                Recurse(str); // Function to remind new directory
            } else {
                if (file.cFileName == "*.txt") {
                    std::wcout &lt;&lt; file.cFileName &lt;&lt; std::endl; //Print files find with estension txt
                }
            }
        } while(FindNextFile(search_handle,&amp;file));

        CloseHandle(search_handle);
    }
}
</code></pre>

<p>Of course I tried it with a static value (<code>*.txt</code>) to see if it worked, but it didn't work when I called it from in main:</p>

<pre><code>Recurse("C:\\*");
</code></pre>