FindNextFile Error

i am working on on zipper program (just like winrar) i had problem with FindNextFileA ,it works fine when dealing with files (not directories) ,but if i had some files and directories it zips the files ok, but it zips one directory and skips the other directories ....i cannot make it clear to you more than this just try to understand me.

i only included the error function (which i think it is all what needed)
if you need the rest of the code just notify me
the error exactly in the call tailed by the comment // **** It Fails here can you help??
thanks for your time
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
bool ZipFolder(char* file,char* Archieve,bool Recursive=false){ //it is Recursive
		if (!comp.isOpen())
			comp.open(Archieve );
		char Temp[MAX_PATH];
		WIN32_FIND_DATAA data;

		StringCchCopyA(Temp,MAX_PATH,file);
		StringCchCatA(Temp,260,"\\*");
		
		HANDLE hFind = FindFirstFileA(Temp,&data);
		if (hFind == INVALID_HANDLE_VALUE) return false;

		StringCchCopyA(Temp,MAX_PATH,file);
		StringCchCatA(Temp,260,"\\");

		StringCchCatA(Temp,260,data.cFileName);
		if(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY && strcmp(data.cFileName,".") && strcmp(data.cFileName,"..")) 
			ZipFolder(Temp,Archieve,true);

		ifstream fil( Temp, ios::in | ios::binary );
		if (fil.is_open())
		{
			comp.addEntry(Temp);
			comp << fil;
		}
		FindNextFileA(hFind,&data);

		while (GetLastError() != ERROR_NO_MORE_FILES)
		{
			StringCchCopyA(Temp,MAX_PATH,file);
			StringCchCatA(Temp,260,"\\");
			StringCchCatA(Temp,260,data.cFileName);

			if(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY && strcmp(data.cFileName,".") && strcmp(data.cFileName,"..")) 
			{
				ZipFolder(Temp,Archieve,true);
				FindNextFileA(hFind,&data); // **** It Fails here can you help??
				continue;
			}
		
			ifstream fil( Temp, ios::in | ios::binary );
			if (fil.is_open())
			{
				comp.addEntry(Temp);
				comp << fil;
			}
			FindNextFileA(hFind,&data);
			
		}
		fil.close();
		if (Recursive == false ) 
			comp.close();
		return true;
}
Topic archived. No new replies allowed.