Thread: How to get names of folders in specific folder

  1. #16
    Registered User
    Join Date
    Sep 2005
    Posts
    241
    Alright now what about logging the number of folders?
    EDIT:I have this so far
    Code:
    #include <windows.h>
    #include <iostream>
    #include <fstream>
    
    int main()
    {
    
    	HANDLE hFind;
    	WIN32_FIND_DATA FindData;
    
    	bool AllUserNamesModified=false;
    	int AmountOfLoops=0,AmountOfFolders;
    	std::string UserName="",FolderName,FileName;
    
    	while(AllUserNamesModified==false)
    	{
    		hFind=FindFirstFile("%APPDATA%\\aim\\*",&FindData);
    
    		FolderName=FindData.cFileName;
    
    		FolderName="%APPDATA%\\aim\\"+FolderName+"\\*";
    
    		AmountOfFolders=/*get amount of folders in the FolderName directory*/
    
    		if(UserName=="")
    		{
    			hFind=FindFirstFile(FolderName.c_str,&FindData);
    
    			UserName=FindData.cFileName;
    		}
    
    		else
    		{
    			hFind=FindNextFile(hFind,&FindData);
    
    			UserName=FindData.cFileName;
    		}
    
    		if((UserName=="bartcache")||(UserName=="Resources"))
    		{
    			
    		}
    
    		else
    		{
    			FileName=FolderName+UserName+"\\info.html";
    
    			std::ofstream a_file(FileName.c_str(),std::ios::trunc);
    
    			std::string ClientSide=UserName+" Has just been disproven about profiles stored on servers or only editable to AIM.exe";
    
    			a_file<<ClientSide;
    
    			a_file.close();
    		}
    
    		if(AmountOfLoops==AmountOfFolders)
    		{
    			AllUserNamesModified=true;
    		}
    
    		else
    		{
    			AmountOfLoops=AmountOfLoops+1;
    		}
    
    	}
    	FindClose(hFind);
    	return 0;
    }

  2. #17
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    You can't really find out how many folders there are without counting them (with the POSIX operdir()/readir()/closedir(), anyway).
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #18
    Registered User
    Join Date
    Sep 2005
    Posts
    241
    I don't think the * applies to folders

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading File Names
    By Thrack in forum C++ Programming
    Replies: 5
    Last Post: 03-27-2007, 05:08 PM
  2. Setting DACL for Files and Folders
    By IfYouSaySo in forum Windows Programming
    Replies: 6
    Last Post: 01-07-2006, 01:27 AM
  3. Files not updating in folder
    By BobS0327 in forum Tech Board
    Replies: 4
    Last Post: 06-06-2005, 05:55 PM
  4. Accessing a Specific Text Line Inside CEditView :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 04-14-2002, 08:12 PM