Archive: Findfirst/next issue


Findfirst/next issue
  Hi,

I am attempting to locate 2 subfolders within a given path and output them to a text file.

The problem i have is locating the second subfolder.

For example :
The full path is
c:\top\mid\parent\child

I already know the c:\top\mid but subfolders parent and child will have different names depending on configuration within a 3rd party application.

Using findfirst i can locate and register the folder 'parent'. I append this to a text file with the original path and search again but this time find nothing.
I have even tried to split the searches into 2 seprate functions - only the parent function returns a result.
Obviously - in testing this i know for sure that folders parent and child exist.


Parent


ClearErrors
FindFirst$0 $1 "C:\top\mid\*.*"
>StrCmp $1 "." +2
StrCpy$2 "$1$\r$\n"

>loop:
>FindNext $0 $1
IfErrors end
StrCmp$1 ".." loop
StrCpy$2 "$2$1$\r$\n"
>goto loop

end:
>StrCmp $2 "" 0 +2
MessageBox MB_OK"Error! No Files found" IDOK +2
MessageBox MB_OK "Files found: $\r$\n$2"

>FileOpen $9 C:Path1.txt w
FileWrite$9 "C:\top\mid\"
FileWrite $9 "
$2"
FileClose $9
FindClose $0

FunctionEnd

Function Child

ClearErrors
FileOpen $3 C:\Path1.txt r
FileRead $3 $4
Messagebox MB_OK "$4"
FindFirst $0 $1 "$4*.*"

StrCmp $1 "." +2
StrCpy $2 "$1$r$n"

loop1:
FindNext $0 $1
IfErrors end
StrCmp $1 ".." loop1
StrCpy $2 "$2$1$r$n"
goto loop1

end:
StrCmp $2 "" 0 +2
MessageBox MB_OK "Error! No Files found" IDOK +2
MessageBox MB_OK "Files found: $r$n$2"

FunctionEnd
>
I think it must be something really simple but i just cant see what it is. Function child returns a blank result - not an error

Can anyone see where i am failing ?

Thanks

Fish

You probably forgot to remove the new lines after reading from the text file again.

Stu