Results 1 to 2 of 2

Thread: FindFirstFile and FindNextFile Problem

  1. #1

    Thread Starter
    Lively Member FantastichenEin's Avatar
    Join Date
    Mar 2000
    Location
    dairy
    Posts
    106

    FindFirstFile and FindNextFile Problem

    Code:
    std::string GetFile(const std::string &path)
    {
    	WIN32_FIND_DATA wfd;
    	static HANDLE hFind;
    	
    	if(path=="")
    	{
    		// We are getting another file
    		if(FindNextFile(hFind, &wfd) == FALSE) return(""); 
    		while(wfd.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
    		{
    			if(FindNextFile(hFind, &wfd) == FALSE) return("");
    		}
    	}
    	else
    	{
    		// We are getting the first file
    		hFind = FindFirstFile(path.c_str(), &wfd);
    		if(hFind == INVALID_HANDLE_VALUE) return("");
    
    	}
    	
    	return(wfd.cFileName);
    }
    I am using the above function to return filenames, I don't want it to return dirs. The problem is that it still returns some dirs (ones like Program Files and Recycle folders) any idea why?

    Thankyou
    ****

  2. #2

    Thread Starter
    Lively Member FantastichenEin's Avatar
    Join Date
    Mar 2000
    Location
    dairy
    Posts
    106

    Resolved

    No worries, I solved it.
    ****

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width