If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: Recursion

What can I do to make the code work?

Debug the code and fix it!

What debugging of this code have you done? What part is not working?

Where are you checking the result of InernetOpen, InternetConnect and UpdateData for errors? What about FtpCreateDirectory and FtpPutFile? How do you know they are not returning errors? What if FindFirstFile doesn't find a file? Everytime you use an API you need to check that it has succeeded and if it has failed unexpectedly then log the reason for the failure.

All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

The code above will take a directory and rip out all the sub directory and put them in the same directory. how can I upload a directory with all its contents inside.? the code above is what I got so far. can someone help out as ihave been trying to get this work..even tried debugging..but no luck

The code above will take a directory and rip out all the sub directory and put them in the same directory. how can I upload a directory with all its contents inside.? the code above is what I got so far. can someone help out as ihave been trying to get this work..even tried debugging..but no luck

First of all, please format your code properly. No one is going to try and read code where their eyes are going back and forth as if they're watching a tennis match.

Remove the "UpdateData" as they are unimportant to the issue. You have a sample of a directory you want to traverse, right? So step through this code and identify where the code deviates from what you expected to occur.

Which function, which line, etc. does it start to go awry or different than what you expect? Is it the IsDots() function? If so, is it returning true when you expected it to return false? Is it the FtpCreateDirectory()? Where is your check for the return code? Does it create a directory, or does it create one with a wrong name? Is it the FindNextFile()? Is it not finding the next file? Is the newPath the correct name? When the code calls recursion again, is it following the path you expected? (you should have some sort of diagram as to what calling recursion() again will do). Etc. Etc.

This is how you debug code. Debugging doesn't mean run code, change code, run code, change code, and in-between these steps, hope for the best. Debugging means to go through the code and see where it deviates from the plan you had in mind by inspecting the variables, return values, etc.

Re: Recursion

So what is the FtpCurrentDirectory at the point you use FtpPutFile? (Use FtpGetCurrentDirectory). From ealier posts, how do you know that FtpCreateDirectory(..) and FtpSetCurrentDirectory(..) have been successful as you are not testing for errors?

All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

What if that function returns FALSE? You should never call functions and just assume that they "work".

Second, since you know what your program is doing wrong, I don't see why you can't just debug your program to see why it's just going to the last subdirectory. Do you know how the program you have is supposed to work? If you do, again, where in the code does it go different than what you expected?

So far, you're telling us on a high-level what is wrong, as if you're not a programmer. Since you now have taken on the mantle of a programmer, you're job is to go at the "programmer level", and that is to run the program under the debugger and noting where the program takes a different path than what you expected.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.