Click here to Skip to main content
15,913,722 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerAlmost solved! Pin
Bob Stanneveld17-May-05 2:59
Bob Stanneveld17-May-05 2:59 
AnswerRe: #define ?? Pin
Tim Smith17-May-05 3:20
Tim Smith17-May-05 3:20 
QuestionUser script or other technique? Pin
lynchspawn17-May-05 2:14
lynchspawn17-May-05 2:14 
AnswerRe: User script or other technique? Pin
Blake Miller17-May-05 5:05
Blake Miller17-May-05 5:05 
GeneralPls help Pin
lgstef17-May-05 2:13
lgstef17-May-05 2:13 
GeneralRe: Pls help Pin
ThatsAlok17-May-05 2:20
ThatsAlok17-May-05 2:20 
GeneralUse SetAccountInformation() Pin
bosfan17-May-05 2:01
bosfan17-May-05 2:01 
Questionget sub-directory count ?? Pin
jdgordy17-May-05 1:47
jdgordy17-May-05 1:47 
hey all,
i need to know how many sub-directories are under a certain direcotry (could be a hard disk)...
at the moment im using the following code and just wlaking the directory tree but its pretty slow.. can some1 help me out and speed it up (or better yet, tell me the win32 api call i dont know abnout which does this all for me )
<br />
int GetFileFolderCount(char* folder, int recurse, char *ignoreFolders, int *folders)<br />
{<br />
	WIN32_FIND_DATA FindFileData;<br />
	HANDLE hFind;<br />
	int fileFound = 1;<br />
	int len = strlen(folder)+5;<br />
	char *searchPath = (char*)malloc(len);<br />
	if (!searchPath) return 0;<br />
	if (folder[strlen(folder)-1]=='\\')<br />
		folder[strlen(folder)-1] = '\0';<br />
	_snprintf(searchPath,len ,"%s\\*.*",folder);<br />
	hFind = FindFirstFile(searchPath, &FindFileData);<br />
	if (hFind == INVALID_HANDLE_VALUE) return 0;<br />
	<br />
	while (fileFound && continueSearch)<br />
	{<br />
		if (recurse && FindFileData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)<br />
		{<br />
			char *newSearch;<br />
			if (!strcmp(FindFileData.cFileName,".") || !strcmp(FindFileData.cFileName,".."))<br />
			{<br />
				fileFound = FindNextFile(hFind,&FindFileData);<br />
				continue;<br />
			}<br />
			len = strlen(folder)+strlen(FindFileData.cFileName)+5;<br />
			newSearch = (char*)malloc(len);<br />
			if (!newSearch) return 0;<br />
			_snprintf(newSearch,len,"%s\\%s\0",folder,FindFileData.cFileName);<br />
			if (!ignorefolder(newSearch,ignoreFolders))<br />
			{<br />
				(*folders)++;<br />
				GetFileFolderCount(newSearch,recurse,ignoreFolders  ,folders);<br />
			}<br />
			free(newSearch);<br />
		}<br />
		else if (!recurse && FindFileData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)<br />
		{<br />
			fileFound = FindNextFile(hFind,&FindFileData);<br />
			continue;	<br />
		}<br />
		fileFound = FindNextFile(hFind,&FindFileData);<br />
	}<br />
	FindClose(hFind);<br />
	free(searchPath);<br />
	return 1;<br />
}<br />

thanx
AnswerRe: get sub-directory count ?? Pin
rocky_pulley17-May-05 3:38
rocky_pulley17-May-05 3:38 
Generalchecking if a file exist or not Pin
toxcct17-May-05 1:43
toxcct17-May-05 1:43 
GeneralRe: checking if a file exist or not Pin
Jack Puppy17-May-05 1:49
Jack Puppy17-May-05 1:49 
GeneralRe: checking if a file exist or not Pin
toxcct17-May-05 1:51
toxcct17-May-05 1:51 
GeneralRe: checking if a file exist or not Pin
ThatsAlok17-May-05 2:10
ThatsAlok17-May-05 2:10 
GeneralRe: checking if a file exist or not Pin
toxcct17-May-05 2:13
toxcct17-May-05 2:13 
GeneralRe: checking if a file exist or not Pin
ThatsAlok17-May-05 2:20
ThatsAlok17-May-05 2:20 
GeneralRe: checking if a file exist or not Pin
Blake Miller17-May-05 5:14
Blake Miller17-May-05 5:14 
GeneralPlease Help Pin
adebrown17-May-05 1:32
adebrown17-May-05 1:32 
GeneralRe: Please Help Pin
ThatsAlok17-May-05 1:43
ThatsAlok17-May-05 1:43 
GeneralRe: Please Help Pin
adebrown17-May-05 2:18
adebrown17-May-05 2:18 
GeneralRe: Please Help Pin
Bob Stanneveld17-May-05 2:15
Bob Stanneveld17-May-05 2:15 
GeneralRe: Please Help Pin
khan++17-May-05 3:04
khan++17-May-05 3:04 
Generalplacing tabs at bottom of property sheet Pin
Muhammad Azam17-May-05 1:30
Muhammad Azam17-May-05 1:30 
GeneralString to Symbol constant conversion Pin
rgchezhian17-May-05 1:24
rgchezhian17-May-05 1:24 
GeneralRe: String to Symbol constant conversion Pin
toxcct17-May-05 1:31
toxcct17-May-05 1:31 
GeneralRe: String to Symbol constant conversion Pin
rgchezhian17-May-05 2:47
rgchezhian17-May-05 2:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.