Navigating Files on a SD card

Hi all,
I am new to programming so wanted a little help, I am trying to build a WAV player, where user will be open to navigate between the files and then select the open they want to play. Moving down the list of file can be done with "root.openNextFile();" function but is there a way of opening previous file. I just want to move up and down the WAV files in the SD card.

Any Help will be wonderful

Thanks

sushanta:
I am new to programming so wanted a little help, I am trying to build a WAV player, where user will be open to navigate between the files and then select the open they want to play. Moving down the list of file can be done with "root.openNextFile();" function but is there a way of opening previous file. I just want to move up and down the WAV files in the SD card.

Count the files you find using "root.openNextFile();" and remember the number of the file currently selected. If you want to move up in the list, Restart the files list and increment through the list forward using "root.openNextFile();" until you reached the remembered number minus one. This is then the previous file.

Thank you, I came to the same conclusion 3 am last night, but got stuck with a new problem. How do you stop the loop once you get to the previous file and Serial.print (file).

sushanta:
Thank you, I came to the same conclusion 3 am last night, but got stuck with a new problem. How do you stop the loop once you get to the previous file and Serial.print (file).

Typically you can abort a loop by using a 'break' statement.

Break statement wasn't working for me but fixed by adding a boolean (true) to get into the loop. Once I got the value I wanted set the boolean as false and the loop is never started again until I need another file. Thanks for the help