When any file is open use the vector to store the names/paths of all the files present in that directory. You need to use vector because you dont know the number of files you will have anc link list will be a more complicated approach. Now when anyone clicks next or previous just display the respected file.